From af76e447527da609965dff5726696b59d6873d6e Mon Sep 17 00:00:00 2001 From: Edward O'Callaghan Date: Thu, 25 Aug 2022 23:11:56 +1000 Subject: flashrom.c: Make 'chip_to_probe' a param to probe_flash() Apart from the very bespoke case of 'probe_w29ee011()' the override 'chip_to_probe' name is a nature parameter to 'probe_flash()'. However we can deal with w29ee011 by providing a probe specific validation function to check if the chip can indeed be overriden. TEST=`./flashrom -p internal --flash-name`. Change-Id: Ifcdace07ea2135d83dea92cfa5c6bec8d7ddf05d Signed-off-by: Edward O'Callaghan Reviewed-on: https://review.coreboot.org/c/flashrom/+/67091 Tested-by: build bot (Jenkins) Reviewed-by: Felix Singer Reviewed-by: Anastasia Klimchuk --- w29ee011.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'w29ee011.c') diff --git a/w29ee011.c b/w29ee011.c index 62d7a0f70..234b865c8 100644 --- a/w29ee011.c +++ b/w29ee011.c @@ -15,9 +15,24 @@ */ #include +#include + #include "flash.h" #include "chipdrivers.h" +bool w29ee011_can_override(const char *const chip_name, const char *const override_chip) +{ + if (!override_chip || strcmp(override_chip, chip_name)) { + msg_cdbg("Old Winbond W29* probe method disabled because " + "the probing sequence puts the AMIC A49LF040A in " + "a funky state. Use 'flashrom -c %s' if you " + "have a board with such a chip.\n", chip_name); + return false; + } + + return true; +} + /* According to the Winbond W29EE011, W29EE012, W29C010M, W29C011A * datasheets this is the only valid probe function for those chips. */ @@ -26,14 +41,6 @@ int probe_w29ee011(struct flashctx *flash) chipaddr bios = flash->virtual_memory; uint8_t id1, id2; - if (!chip_to_probe || strcmp(chip_to_probe, flash->chip->name)) { - msg_cdbg("Old Winbond W29* probe method disabled because " - "the probing sequence puts the AMIC A49LF040A in " - "a funky state. Use 'flashrom -c %s' if you " - "have a board with such a chip.\n", flash->chip->name); - return 0; - } - /* Issue JEDEC Product ID Entry command */ chip_writeb(flash, 0xAA, bios + 0x5555); programmer_delay(flash, 10); -- cgit v1.2.3