mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-28 15:33:42 +02:00
sb600spi.c: Consolidate smbus dev revision derivation
V.2: Rename 'find_smbus_dev()' -> 'find_smbus_dev_rev()'. Change-Id: I766b29cc1c7d01aa0bcf6cb9ff5ab73fa1995dcd Signed-off-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/36420 Reviewed-by: Patrick Georgi <pgeorgi@google.com> Reviewed-by: Nico Huber <nico.h@gmx.de> Tested-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
parent
2d20d6db39
commit
c0a27e1f17
30
sb600spi.c
30
sb600spi.c
@ -80,6 +80,17 @@ static struct spi_master spi_master_yangtze = {
|
|||||||
.write_aai = default_spi_write_aai,
|
.write_aai = default_spi_write_aai,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int find_smbus_dev_rev(uint16_t vendor, uint16_t device)
|
||||||
|
{
|
||||||
|
struct pci_dev *smbus_dev = pci_dev_find(vendor, device);
|
||||||
|
if (!smbus_dev) {
|
||||||
|
msg_pdbg("No SMBus device with ID %04X:%04X found.\n", vendor, device);
|
||||||
|
msg_perr("ERROR: SMBus device not found. Not enabling SPI.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return pci_read_byte(smbus_dev, PCI_REVISION_ID);
|
||||||
|
}
|
||||||
|
|
||||||
static void determine_generation(struct pci_dev *dev)
|
static void determine_generation(struct pci_dev *dev)
|
||||||
{
|
{
|
||||||
amd_gen = CHIPSET_AMD_UNKNOWN;
|
amd_gen = CHIPSET_AMD_UNKNOWN;
|
||||||
@ -88,10 +99,9 @@ static void determine_generation(struct pci_dev *dev)
|
|||||||
amd_gen = CHIPSET_SB6XX;
|
amd_gen = CHIPSET_SB6XX;
|
||||||
msg_pdbg("SB6xx detected.\n");
|
msg_pdbg("SB6xx detected.\n");
|
||||||
} else if (dev->device_id == 0x439d) {
|
} else if (dev->device_id == 0x439d) {
|
||||||
struct pci_dev *smbus_dev = pci_dev_find(0x1002, 0x4385);
|
int rev = find_smbus_dev_rev(0x1002, 0x4385);
|
||||||
if (smbus_dev == NULL)
|
if (rev < 0)
|
||||||
return;
|
return;
|
||||||
uint8_t rev = pci_read_byte(smbus_dev, PCI_REVISION_ID);
|
|
||||||
if (rev >= 0x39 && rev <= 0x3D) {
|
if (rev >= 0x39 && rev <= 0x3D) {
|
||||||
amd_gen = CHIPSET_SB7XX;
|
amd_gen = CHIPSET_SB7XX;
|
||||||
msg_pdbg("SB7xx/SP5100 detected.\n");
|
msg_pdbg("SB7xx/SP5100 detected.\n");
|
||||||
@ -123,12 +133,9 @@ static void determine_generation(struct pci_dev *dev)
|
|||||||
msg_pdbg("not found. Assuming Hudson.\n");
|
msg_pdbg("not found. Assuming Hudson.\n");
|
||||||
amd_gen = CHIPSET_HUDSON234;
|
amd_gen = CHIPSET_HUDSON234;
|
||||||
#else
|
#else
|
||||||
struct pci_dev *smbus_dev = pci_dev_find(0x1022, 0x780B);
|
int rev = find_smbus_dev_rev(0x1022, 0x780B);
|
||||||
if (smbus_dev == NULL) {
|
if (rev < 0)
|
||||||
msg_pdbg("No SMBus device with ID 1022:780B found.\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
uint8_t rev = pci_read_byte(smbus_dev, PCI_REVISION_ID);
|
|
||||||
if (rev >= 0x11 && rev <= 0x15) {
|
if (rev >= 0x11 && rev <= 0x15) {
|
||||||
amd_gen = CHIPSET_HUDSON234;
|
amd_gen = CHIPSET_HUDSON234;
|
||||||
msg_pdbg("Hudson-2/3/4 detected.\n");
|
msg_pdbg("Hudson-2/3/4 detected.\n");
|
||||||
@ -144,12 +151,9 @@ static void determine_generation(struct pci_dev *dev)
|
|||||||
"the output of lspci -nnvx, thanks!.\n", rev);
|
"the output of lspci -nnvx, thanks!.\n", rev);
|
||||||
}
|
}
|
||||||
} else if (dev->device_id == 0x790e) {
|
} else if (dev->device_id == 0x790e) {
|
||||||
struct pci_dev *smbus_dev = pci_dev_find(0x1022, 0x790B);
|
int rev = find_smbus_dev_rev(0x1022, 0x790B);
|
||||||
if (smbus_dev == NULL) {
|
if (rev < 0)
|
||||||
msg_pdbg("No SMBus device with ID 1022:790B found.\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
uint8_t rev = pci_read_byte(smbus_dev, PCI_REVISION_ID);
|
|
||||||
if (rev == 0x4a) {
|
if (rev == 0x4a) {
|
||||||
amd_gen = CHIPSET_YANGTZE;
|
amd_gen = CHIPSET_YANGTZE;
|
||||||
msg_pdbg("Yangtze detected.\n");
|
msg_pdbg("Yangtze detected.\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user