aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward O'Callaghan <quasisec@chromium.org>2019-10-29 18:18:18 +1100
committerNico Huber <nico.h@gmx.de>2019-11-14 22:42:22 +0000
commit9355e6faf66653655cef5ab312c00e70582fe595 (patch)
treef270bcba5757d3efa66f841d697aa25956a3d485
parentc0a27e1f1748650726d81f1c00c1ebd440f3ea38 (diff)
downloadflashrom-9355e6faf66653655cef5ab312c00e70582fe595.tar.gz
flashrom-9355e6faf66653655cef5ab312c00e70582fe595.tar.bz2
flashrom-9355e6faf66653655cef5ab312c00e70582fe595.zip
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>
-rw-r--r--sb600spi.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/sb600spi.c b/sb600spi.c
index 6466795b..050d2104 100644
--- a/sb600spi.c
+++ b/sb600spi.c
@@ -91,7 +91,8 @@ static int find_smbus_dev_rev(uint16_t vendor, uint16_t device)
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 @@ static void determine_generation(struct pci_dev *dev)
} 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 @@ static void determine_generation(struct pci_dev *dev)
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 @@ static void determine_generation(struct pci_dev *dev)
#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 @@ static void determine_generation(struct pci_dev *dev)
} 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 @@ static void determine_generation(struct pci_dev *dev)
"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 @@ int sb600_probe_spi(struct pci_dev *dev)
*/
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.