Nico Huber submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Nico Huber: Looks good to me, but someone else must approve Arthur Heymans: Looks good to me, approved
sb600spi.c: Fold up debug logic into determine_generation()

Change-Id: I6c722e29b321285bf20fb5ee30c912dcdd83411b
Signed-off-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/36425
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
---
M sb600spi.c
1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/sb600spi.c b/sb600spi.c
index 6466795..050d210 100644
--- a/sb600spi.c
+++ b/sb600spi.c
@@ -91,7 +91,8 @@
return pci_read_byte(smbus_dev, PCI_REVISION_ID);
}

-static void determine_generation(struct pci_dev *dev)
+/* Determine the chipset's version and identify the respective SMBUS device. */
+static int determine_generation(struct pci_dev *dev)
{
amd_gen = CHIPSET_AMD_UNKNOWN;
msg_pdbg2("Trying to determine the generation of the SPI interface... ");
@@ -101,7 +102,7 @@
} else if (dev->device_id == 0x439d) {
int rev = find_smbus_dev_rev(0x1002, 0x4385);
if (rev < 0)
- return;
+ return -1;
if (rev >= 0x39 && rev <= 0x3D) {
amd_gen = CHIPSET_SB7XX;
msg_pdbg("SB7xx/SP5100 detected.\n");
@@ -127,7 +128,7 @@
if (mmio_readb(sb600_spibar + i) != 0xff) {
amd_gen = CHIPSET_YANGTZE;
msg_pdbg("found.\n");
- return;
+ return 0;
}
}
msg_pdbg("not found. Assuming Hudson.\n");
@@ -135,7 +136,7 @@
#else
int rev = find_smbus_dev_rev(0x1022, 0x780B);
if (rev < 0)
- return;
+ return -1;
if (rev >= 0x11 && rev <= 0x15) {
amd_gen = CHIPSET_HUDSON234;
msg_pdbg("Hudson-2/3/4 detected.\n");
@@ -153,7 +154,7 @@
} else if (dev->device_id == 0x790e) {
int rev = find_smbus_dev_rev(0x1022, 0x790B);
if (rev < 0)
- return;
+ return -1;
if (rev == 0x4a) {
amd_gen = CHIPSET_YANGTZE;
msg_pdbg("Yangtze detected.\n");
@@ -170,6 +171,11 @@
"Please report this to flashrom@flashrom.org and include this log and\n"
"the output of lspci -nnvx, thanks!\n",
__func__, dev->vendor_id, dev->device_id);
+ if (amd_gen == CHIPSET_AMD_UNKNOWN) {
+ msg_perr("Could not determine chipset generation.");
+ return -1;
+ }
+ return 0;
}

static void reset_internal_fifo_pointer(void)
@@ -565,11 +571,8 @@
*/
sb600_spibar += tmp & 0xfff;

- determine_generation(dev);
- if (amd_gen == CHIPSET_AMD_UNKNOWN) {
- msg_perr("Could not determine chipset generation.");
+ if (determine_generation(dev) < 0)
return ERROR_NONFATAL;
- }

/* How to read the following table and similar ones in this file:
* "?" means we have no datasheet for this chipset generation or it doesn't have any relevant info.

To view, visit change 36425. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I6c722e29b321285bf20fb5ee30c912dcdd83411b
Gerrit-Change-Number: 36425
Gerrit-PatchSet: 4
Gerrit-Owner: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-Reviewer: Arthur Heymans <arthur@aheymans.xyz>
Gerrit-Reviewer: Nico Huber <nico.h@gmx.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-MessageType: merged