platform/x86: p2sb: Don't fail if unknown CPU is found
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Fri, 4 Nov 2022 15:49:16 +0000 (17:49 +0200)
committerHans de Goede <hdegoede@redhat.com>
Mon, 7 Nov 2022 11:33:49 +0000 (12:33 +0100)
We have accessing P2SB from a very few places for quite known hardware.

When a new SoC appears in intel-family.h it's not obvious that it needs
to be added to p2sb.c as well. Instead, provide default BDF and refactor
p2sb_get_devfn() to always succeed. If in the future we would need to
exclude something, we may add a list of unsupported IDs.

Without this change the iTCO on Intel Comet Lake SoCs became unavailable:

  i801_smbus 0000:00:1f.4: failed to create iTCO device

Fixes: 5c7b9167ddf8 ("i2c: i801: convert to use common P2SB accessor")
Reported-and-tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20221104154916.35231-1-andriy.shevchenko@linux.intel.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/platform/x86/p2sb.c

index 384d0962ae93ab0d840d9e19f00ca85cdcd46bc3..1cf2471d54ddef765b017fd079864b3ffb868fdc 100644 (file)
 #define P2SBC                  0xe0
 #define P2SBC_HIDE             BIT(8)
 
+#define P2SB_DEVFN_DEFAULT     PCI_DEVFN(31, 1)
+
 static const struct x86_cpu_id p2sb_cpu_ids[] = {
        X86_MATCH_INTEL_FAM6_MODEL(ATOM_GOLDMONT,       PCI_DEVFN(13, 0)),
-       X86_MATCH_INTEL_FAM6_MODEL(ATOM_GOLDMONT_D,     PCI_DEVFN(31, 1)),
-       X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT_D,   PCI_DEVFN(31, 1)),
-       X86_MATCH_INTEL_FAM6_MODEL(KABYLAKE,            PCI_DEVFN(31, 1)),
-       X86_MATCH_INTEL_FAM6_MODEL(KABYLAKE_L,          PCI_DEVFN(31, 1)),
-       X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE,             PCI_DEVFN(31, 1)),
-       X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE_L,           PCI_DEVFN(31, 1)),
        {}
 };
 
 static int p2sb_get_devfn(unsigned int *devfn)
 {
+       unsigned int fn = P2SB_DEVFN_DEFAULT;
        const struct x86_cpu_id *id;
 
        id = x86_match_cpu(p2sb_cpu_ids);
-       if (!id)
-               return -ENODEV;
+       if (id)
+               fn = (unsigned int)id->driver_data;
 
-       *devfn = (unsigned int)id->driver_data;
+       *devfn = fn;
        return 0;
 }