x86/amd_nb: Add support for Hygon family 18h model 5h

Add root and DF F1/F3/F4 device IDs for Hygon family 18h model
5h processors. But some model 5h processors have the legacy(M04H)
DF devices, so add a if conditional to read the df1 register.

Signed-off-by: Pu Wen <puwen@hygon.cn>
Signed-off-by: Jinliang Zheng <alexjlzheng@tencent.com>
Reviewed-by: Bin Lai <robinlai@tencent.com>
Signed-off-by: Jinliang Zheng <alexjlzheng@tencent.com>
Reviewed-by: caelli <caelli@tencent.com>
Signed-off-by: Jianping Liu <frankjpliu@tencent.com>
This commit is contained in:
Pu Wen 2023-06-08 12:46:43 +08:00 committed by Jianping Liu
parent 9c869204b2
commit 2c598bc5d1
2 changed files with 23 additions and 2 deletions

View File

@ -28,7 +28,10 @@
#define PCI_DEVICE_ID_AMD_19H_DF_F4 0x1654
#define PCI_DEVICE_ID_AMD_19H_M10H_DF_F4 0x14b1
#define PCI_DEVICE_ID_HYGON_18H_M05H_ROOT 0x14a0
#define PCI_DEVICE_ID_HYGON_18H_M04H_DF_F1 0x1491
#define PCI_DEVICE_ID_HYGON_18H_M05H_DF_F1 0x14b1
#define PCI_DEVICE_ID_HYGON_18H_M05H_DF_F4 0x14b4
/* Protect the PCI config register pairs used for SMN and DF indirect access. */
static DEFINE_MUTEX(smn_mutex);
@ -89,18 +92,21 @@ static const struct pci_device_id amd_nb_link_ids[] = {
static const struct pci_device_id hygon_root_ids[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_HYGON, PCI_DEVICE_ID_AMD_17H_ROOT) },
{ PCI_DEVICE(PCI_VENDOR_ID_HYGON, PCI_DEVICE_ID_AMD_17H_M30H_ROOT) },
{ PCI_DEVICE(PCI_VENDOR_ID_HYGON, PCI_DEVICE_ID_HYGON_18H_M05H_ROOT) },
{}
};
static const struct pci_device_id hygon_nb_misc_ids[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_HYGON, PCI_DEVICE_ID_AMD_17H_DF_F3) },
{ PCI_DEVICE(PCI_VENDOR_ID_HYGON, PCI_DEVICE_ID_AMD_17H_M30H_DF_F3) },
{ PCI_DEVICE(PCI_VENDOR_ID_HYGON, PCI_DEVICE_ID_HYGON_18H_M05H_DF_F3) },
{}
};
static const struct pci_device_id hygon_nb_link_ids[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_HYGON, PCI_DEVICE_ID_AMD_17H_DF_F4) },
{ PCI_DEVICE(PCI_VENDOR_ID_HYGON, PCI_DEVICE_ID_AMD_17H_M30H_DF_F4) },
{ PCI_DEVICE(PCI_VENDOR_ID_HYGON, PCI_DEVICE_ID_HYGON_18H_M05H_DF_F4) },
{}
};
@ -258,10 +264,24 @@ EXPORT_SYMBOL_GPL(hygon_nb_num);
static int get_df1_register(struct pci_dev *misc, int offset, u32 *value)
{
struct pci_dev *df_f1 = NULL;
u32 device;
int err;
while ((df_f1 = pci_get_device(misc->vendor,
PCI_DEVICE_ID_HYGON_18H_M04H_DF_F1, df_f1)))
switch (boot_cpu_data.x86_model) {
case 0x4:
device = PCI_DEVICE_ID_HYGON_18H_M04H_DF_F1;
break;
case 0x5:
if (misc->device == PCI_DEVICE_ID_HYGON_18H_M05H_DF_F3)
device = PCI_DEVICE_ID_HYGON_18H_M05H_DF_F1;
else
device = PCI_DEVICE_ID_HYGON_18H_M04H_DF_F1;
break;
default:
return -ENODEV;
}
while ((df_f1 = pci_get_device(misc->vendor, device, df_f1)))
if (pci_domain_nr(df_f1->bus) == pci_domain_nr(misc->bus) &&
df_f1->bus->number == misc->bus->number &&
PCI_SLOT(df_f1->devfn) == PCI_SLOT(misc->devfn))

View File

@ -2599,6 +2599,7 @@
#define PCI_VENDOR_ID_ZHAOXIN 0x1d17
#define PCI_VENDOR_ID_HYGON 0x1d94
#define PCI_DEVICE_ID_HYGON_18H_M05H_DF_F3 0x14b3
#define PCI_VENDOR_ID_HXT 0x1dbf