]> Git Repo - linux.git/commitdiff
platform/x86: p2sb: Move out of X86_PLATFORM_DEVICES dependency
authorAndy Shevchenko <[email protected]>
Mon, 18 Jul 2022 14:53:28 +0000 (17:53 +0300)
committerHans de Goede <[email protected]>
Mon, 1 Aug 2022 14:26:38 +0000 (16:26 +0200)
The P2SB library is used for various drivers, including server
platforms. That's why the dependency on X86_PLATFORM_DEVICES
seems superfluous.

Reported-by: kernel test robot <[email protected]>
Signed-off-by: Andy Shevchenko <[email protected]>
Reviewed-by: Hans de Goede <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Hans de Goede <[email protected]>
drivers/platform/x86/Kconfig
drivers/platform/x86/Makefile
drivers/platform/x86/intel/Kconfig
drivers/platform/x86/intel/Makefile
drivers/platform/x86/intel/p2sb.c [deleted file]
drivers/platform/x86/p2sb.c [new file with mode: 0644]

index 6a33c862452b494bb23fdcde643ce3044f6ae9b9..f2f98e942cf295e1b6d0769abe6500695f42b005 100644 (file)
@@ -1138,3 +1138,15 @@ config WINMATE_FM07_KEYS
          that delivers key events when these buttons are pressed.
 
 endif # X86_PLATFORM_DEVICES
+
+config P2SB
+       bool "Primary to Sideband (P2SB) bridge access support"
+       depends on PCI && X86
+       help
+         The Primary to Sideband (P2SB) bridge is an interface to some
+         PCI devices connected through it. In particular, SPI NOR controller
+         in Intel Apollo Lake SoC is one of such devices.
+
+         The main purpose of this library is to unhide P2SB device in case
+         firmware kept it hidden on some platforms in order to access devices
+         behind it.
index a0e417c34a9bf58092ab169792d81196de252f3d..5a428caa654a742875e46dfb0146c1d1c74db4f9 100644 (file)
@@ -119,6 +119,10 @@ obj-$(CONFIG_X86_ANDROID_TABLETS)  += x86-android-tablets.o
 # Intel uncore drivers
 obj-$(CONFIG_INTEL_IPS)                                += intel_ips.o
 
+# Intel miscellaneous drivers
+intel_p2sb-y                           := p2sb.o
+obj-$(CONFIG_P2SB)                     += intel_p2sb.o
+
 # Intel PMIC / PMC / P-Unit devices
 obj-$(CONFIG_INTEL_SCU_IPC)            += intel_scu_ipc.o
 obj-$(CONFIG_INTEL_SCU_PCI)            += intel_scu_pcidrv.o
index c9cfbaae436b7ce3c747879a09713f61c6e9057b..794968bda1153dca27f9a3abc96cd5253c745507 100644 (file)
@@ -70,18 +70,6 @@ config INTEL_OAKTRAIL
          enable/disable the Camera, WiFi, BT etc. devices. If in doubt, say Y
          here; it will only load on supported platforms.
 
-config P2SB
-       bool "Primary to Sideband (P2SB) bridge access support"
-       depends on PCI
-       help
-         The Primary to Sideband (P2SB) bridge is an interface to some
-         PCI devices connected through it. In particular, SPI NOR controller
-         in Intel Apollo Lake SoC is one of such devices.
-
-         The main purpose of this library is to unhide P2SB device in case
-         firmware kept it hidden on some platforms in order to access devices
-         behind it.
-
 config INTEL_BXTWC_PMIC_TMU
        tristate "Intel Broxton Whiskey Cove TMU Driver"
        depends on INTEL_SOC_PMIC_BXTWC
index 741a9404db989ab109481a36a7d817db88f82cb8..717933dd0cfdd764e77cb345d887a2772c5bb202 100644 (file)
@@ -28,8 +28,6 @@ intel_int0002_vgpio-y                 := int0002_vgpio.o
 obj-$(CONFIG_INTEL_INT0002_VGPIO)      += intel_int0002_vgpio.o
 intel_oaktrail-y                       := oaktrail.o
 obj-$(CONFIG_INTEL_OAKTRAIL)           += intel_oaktrail.o
-intel_p2sb-y                           := p2sb.o
-obj-$(CONFIG_P2SB)                     += intel_p2sb.o
 intel_sdsi-y                           := sdsi.o
 obj-$(CONFIG_INTEL_SDSI)               += intel_sdsi.o
 intel_vsec-y                           := vsec.o
diff --git a/drivers/platform/x86/intel/p2sb.c b/drivers/platform/x86/intel/p2sb.c
deleted file mode 100644 (file)
index fb2e141..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Primary to Sideband (P2SB) bridge access support
- *
- * Copyright (c) 2017, 2021-2022 Intel Corporation.
- *
- * Authors: Andy Shevchenko <[email protected]>
- *         Jonathan Yong <[email protected]>
- */
-
-#include <linux/bits.h>
-#include <linux/export.h>
-#include <linux/pci.h>
-#include <linux/platform_data/x86/p2sb.h>
-
-#include <asm/cpu_device_id.h>
-#include <asm/intel-family.h>
-
-#define P2SBC                  0xe0
-#define P2SBC_HIDE             BIT(8)
-
-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)
-{
-       const struct x86_cpu_id *id;
-
-       id = x86_match_cpu(p2sb_cpu_ids);
-       if (!id)
-               return -ENODEV;
-
-       *devfn = (unsigned int)id->driver_data;
-       return 0;
-}
-
-static int p2sb_read_bar0(struct pci_dev *pdev, struct resource *mem)
-{
-       /* Copy resource from the first BAR of the device in question */
-       *mem = pdev->resource[0];
-       return 0;
-}
-
-static int p2sb_scan_and_read(struct pci_bus *bus, unsigned int devfn, struct resource *mem)
-{
-       struct pci_dev *pdev;
-       int ret;
-
-       pdev = pci_scan_single_device(bus, devfn);
-       if (!pdev)
-               return -ENODEV;
-
-       ret = p2sb_read_bar0(pdev, mem);
-
-       pci_stop_and_remove_bus_device(pdev);
-       return ret;
-}
-
-/**
- * p2sb_bar - Get Primary to Sideband (P2SB) bridge device BAR
- * @bus: PCI bus to communicate with
- * @devfn: PCI slot and function to communicate with
- * @mem: memory resource to be filled in
- *
- * The BIOS prevents the P2SB device from being enumerated by the PCI
- * subsystem, so we need to unhide and hide it back to lookup the BAR.
- *
- * if @bus is NULL, the bus 0 in domain 0 will be used.
- * If @devfn is 0, it will be replaced by devfn of the P2SB device.
- *
- * Caller must provide a valid pointer to @mem.
- *
- * Locking is handled by pci_rescan_remove_lock mutex.
- *
- * Return:
- * 0 on success or appropriate errno value on error.
- */
-int p2sb_bar(struct pci_bus *bus, unsigned int devfn, struct resource *mem)
-{
-       struct pci_dev *pdev_p2sb;
-       unsigned int devfn_p2sb;
-       u32 value = P2SBC_HIDE;
-       int ret;
-
-       /* Get devfn for P2SB device itself */
-       ret = p2sb_get_devfn(&devfn_p2sb);
-       if (ret)
-               return ret;
-
-       /* if @bus is NULL, use bus 0 in domain 0 */
-       bus = bus ?: pci_find_bus(0, 0);
-
-       /*
-        * Prevent concurrent PCI bus scan from seeing the P2SB device and
-        * removing via sysfs while it is temporarily exposed.
-        */
-       pci_lock_rescan_remove();
-
-       /* Unhide the P2SB device, if needed */
-       pci_bus_read_config_dword(bus, devfn_p2sb, P2SBC, &value);
-       if (value & P2SBC_HIDE)
-               pci_bus_write_config_dword(bus, devfn_p2sb, P2SBC, 0);
-
-       pdev_p2sb = pci_scan_single_device(bus, devfn_p2sb);
-       if (devfn)
-               ret = p2sb_scan_and_read(bus, devfn, mem);
-       else
-               ret = p2sb_read_bar0(pdev_p2sb, mem);
-       pci_stop_and_remove_bus_device(pdev_p2sb);
-
-       /* Hide the P2SB device, if it was hidden */
-       if (value & P2SBC_HIDE)
-               pci_bus_write_config_dword(bus, devfn_p2sb, P2SBC, P2SBC_HIDE);
-
-       pci_unlock_rescan_remove();
-
-       if (ret)
-               return ret;
-
-       if (mem->flags == 0)
-               return -ENODEV;
-
-       return 0;
-}
-EXPORT_SYMBOL_GPL(p2sb_bar);
diff --git a/drivers/platform/x86/p2sb.c b/drivers/platform/x86/p2sb.c
new file mode 100644 (file)
index 0000000..fb2e141
--- /dev/null
@@ -0,0 +1,133 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Primary to Sideband (P2SB) bridge access support
+ *
+ * Copyright (c) 2017, 2021-2022 Intel Corporation.
+ *
+ * Authors: Andy Shevchenko <[email protected]>
+ *         Jonathan Yong <[email protected]>
+ */
+
+#include <linux/bits.h>
+#include <linux/export.h>
+#include <linux/pci.h>
+#include <linux/platform_data/x86/p2sb.h>
+
+#include <asm/cpu_device_id.h>
+#include <asm/intel-family.h>
+
+#define P2SBC                  0xe0
+#define P2SBC_HIDE             BIT(8)
+
+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)
+{
+       const struct x86_cpu_id *id;
+
+       id = x86_match_cpu(p2sb_cpu_ids);
+       if (!id)
+               return -ENODEV;
+
+       *devfn = (unsigned int)id->driver_data;
+       return 0;
+}
+
+static int p2sb_read_bar0(struct pci_dev *pdev, struct resource *mem)
+{
+       /* Copy resource from the first BAR of the device in question */
+       *mem = pdev->resource[0];
+       return 0;
+}
+
+static int p2sb_scan_and_read(struct pci_bus *bus, unsigned int devfn, struct resource *mem)
+{
+       struct pci_dev *pdev;
+       int ret;
+
+       pdev = pci_scan_single_device(bus, devfn);
+       if (!pdev)
+               return -ENODEV;
+
+       ret = p2sb_read_bar0(pdev, mem);
+
+       pci_stop_and_remove_bus_device(pdev);
+       return ret;
+}
+
+/**
+ * p2sb_bar - Get Primary to Sideband (P2SB) bridge device BAR
+ * @bus: PCI bus to communicate with
+ * @devfn: PCI slot and function to communicate with
+ * @mem: memory resource to be filled in
+ *
+ * The BIOS prevents the P2SB device from being enumerated by the PCI
+ * subsystem, so we need to unhide and hide it back to lookup the BAR.
+ *
+ * if @bus is NULL, the bus 0 in domain 0 will be used.
+ * If @devfn is 0, it will be replaced by devfn of the P2SB device.
+ *
+ * Caller must provide a valid pointer to @mem.
+ *
+ * Locking is handled by pci_rescan_remove_lock mutex.
+ *
+ * Return:
+ * 0 on success or appropriate errno value on error.
+ */
+int p2sb_bar(struct pci_bus *bus, unsigned int devfn, struct resource *mem)
+{
+       struct pci_dev *pdev_p2sb;
+       unsigned int devfn_p2sb;
+       u32 value = P2SBC_HIDE;
+       int ret;
+
+       /* Get devfn for P2SB device itself */
+       ret = p2sb_get_devfn(&devfn_p2sb);
+       if (ret)
+               return ret;
+
+       /* if @bus is NULL, use bus 0 in domain 0 */
+       bus = bus ?: pci_find_bus(0, 0);
+
+       /*
+        * Prevent concurrent PCI bus scan from seeing the P2SB device and
+        * removing via sysfs while it is temporarily exposed.
+        */
+       pci_lock_rescan_remove();
+
+       /* Unhide the P2SB device, if needed */
+       pci_bus_read_config_dword(bus, devfn_p2sb, P2SBC, &value);
+       if (value & P2SBC_HIDE)
+               pci_bus_write_config_dword(bus, devfn_p2sb, P2SBC, 0);
+
+       pdev_p2sb = pci_scan_single_device(bus, devfn_p2sb);
+       if (devfn)
+               ret = p2sb_scan_and_read(bus, devfn, mem);
+       else
+               ret = p2sb_read_bar0(pdev_p2sb, mem);
+       pci_stop_and_remove_bus_device(pdev_p2sb);
+
+       /* Hide the P2SB device, if it was hidden */
+       if (value & P2SBC_HIDE)
+               pci_bus_write_config_dword(bus, devfn_p2sb, P2SBC, P2SBC_HIDE);
+
+       pci_unlock_rescan_remove();
+
+       if (ret)
+               return ret;
+
+       if (mem->flags == 0)
+               return -ENODEV;
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(p2sb_bar);
This page took 0.068582 seconds and 4 git commands to generate.