platform/x86: intel_atomisp2: Move to intel sub-directory
authorKate Hsuan <hpa@redhat.com>
Fri, 20 Aug 2021 11:04:52 +0000 (14:04 +0300)
committerHans de Goede <hdegoede@redhat.com>
Fri, 20 Aug 2021 18:11:23 +0000 (20:11 +0200)
Move Intel AtomISP v2 drivers to intel sub-directory
to improve readability.

Signed-off-by: Kate Hsuan <hpa@redhat.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210820110458.73018-15-andriy.shevchenko@linux.intel.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
MAINTAINERS
drivers/platform/x86/Kconfig
drivers/platform/x86/Makefile
drivers/platform/x86/intel/Kconfig
drivers/platform/x86/intel/Makefile
drivers/platform/x86/intel/atomisp2/Kconfig [new file with mode: 0644]
drivers/platform/x86/intel/atomisp2/Makefile [new file with mode: 0644]
drivers/platform/x86/intel/atomisp2/led.c [new file with mode: 0644]
drivers/platform/x86/intel/atomisp2/pm.c [new file with mode: 0644]
drivers/platform/x86/intel_atomisp2_led.c [deleted file]
drivers/platform/x86/intel_atomisp2_pm.c [deleted file]

index cf29f71548895839510a13f93bec4fbb74171327..429b8b5c528398757973d8973dbabcc6beb36e7b 100644 (file)
@@ -9212,13 +9212,13 @@ INTEL ATOMISP2 DUMMY / POWER-MANAGEMENT DRIVER
 M:     Hans de Goede <hdegoede@redhat.com>
 L:     platform-driver-x86@vger.kernel.org
 S:     Maintained
-F:     drivers/platform/x86/intel_atomisp2_pm.c
+F:     drivers/platform/x86/intel/atomisp2/pm.c
 
 INTEL ATOMISP2 LED DRIVER
 M:     Hans de Goede <hdegoede@redhat.com>
 L:     platform-driver-x86@vger.kernel.org
 S:     Maintained
-F:     drivers/platform/x86/intel_atomisp2_led.c
+F:     drivers/platform/x86/intel/atomisp2/led.c
 
 INTEL BIOS SAR INT1092 DRIVER
 M:     Shravan S <s.shravan@intel.com>
index 935116ef2df97246408b9954a7a6ad93c53c2a0d..6de0d374ba16013921dfe5926db03dd9076a3da1 100644 (file)
@@ -668,40 +668,6 @@ config THINKPAD_LMI
 
 source "drivers/platform/x86/intel/Kconfig"
 
-config INTEL_ATOMISP2_LED
-       tristate "Intel AtomISP2 camera LED driver"
-       depends on GPIOLIB && LEDS_GPIO
-       help
-         Many Bay Trail and Cherry Trail devices come with a camera attached
-         to Intel's Image Signal Processor. Linux currently does not have a
-         driver for these, so they do not work as a camera. Some of these
-         camera's have a LED which is controlled through a GPIO.
-
-         Some of these devices have a firmware issue where the LED gets turned
-         on at boot. This driver will turn the LED off at boot and also allows
-         controlling the LED (repurposing it) through the sysfs LED interface.
-
-         Which GPIO is attached to the LED is usually not described in the
-         ACPI tables, so this driver contains per-system info about the GPIO
-         inside the driver, this means that this driver only works on systems
-         the driver knows about.
-
-         To compile this driver as a module, choose M here: the module
-         will be called intel_atomisp2_led.
-
-config INTEL_ATOMISP2_PM
-       tristate "Intel AtomISP2 dummy / power-management driver"
-       depends on PCI && IOSF_MBI && PM
-       depends on !INTEL_ATOMISP
-       help
-         Power-management driver for Intel's Image Signal Processor found on
-         Bay Trail and Cherry Trail devices. This dummy driver's sole purpose
-         is to turn the ISP off (put it in D3) to save power and to allow
-         entering of S0ix modes.
-
-         To compile this driver as a module, choose M here: the module
-         will be called intel_atomisp2_pm.
-
 config INTEL_HID_EVENT
        tristate "INTEL HID Event"
        depends on ACPI
index dd3f1e683f0df1cd967ddc2755b3045b7221ede7..dccd7ecaae6ad0c8f81dc85c25f69b2ff522af4d 100644 (file)
@@ -71,8 +71,6 @@ obj-$(CONFIG_THINKPAD_LMI)    += think-lmi.o
 # Intel
 obj-$(CONFIG_X86_PLATFORM_DRIVERS_INTEL)               += intel/
 
-obj-$(CONFIG_INTEL_ATOMISP2_LED)       += intel_atomisp2_led.o
-obj-$(CONFIG_INTEL_ATOMISP2_PM)                += intel_atomisp2_pm.o
 obj-$(CONFIG_INTEL_HID_EVENT)          += intel-hid.o
 obj-$(CONFIG_INTEL_INT0002_VGPIO)      += intel_int0002_vgpio.o
 obj-$(CONFIG_INTEL_OAKTRAIL)           += intel_oaktrail.o
index 2622653af37a667412c930a7f316731adaf83ca9..9d0bc76a89488cb3390e0a35747e1bbfac597dd7 100644 (file)
@@ -16,6 +16,7 @@ menuconfig X86_PLATFORM_DRIVERS_INTEL
 
 if X86_PLATFORM_DRIVERS_INTEL
 
+source "drivers/platform/x86/intel/atomisp2/Kconfig"
 source "drivers/platform/x86/intel/int1092/Kconfig"
 source "drivers/platform/x86/intel/int33fe/Kconfig"
 source "drivers/platform/x86/intel/int3472/Kconfig"
index f5ac4a5f953f29ee9d31a5597a5ba67f4f3a49d2..080589b3082d631494fcbba31ec63ff3062b5ace 100644 (file)
@@ -4,6 +4,7 @@
 # Intel x86 Platform-Specific Drivers
 #
 
+obj-$(CONFIG_INTEL_ATOMISP2_PDX86)     += atomisp2/
 obj-$(CONFIG_INTEL_SAR_INT1092)                += int1092/
 obj-$(CONFIG_INTEL_CHT_INT33FE)                += int33fe/
 obj-$(CONFIG_INTEL_SKL_INT3472)                += int3472/
diff --git a/drivers/platform/x86/intel/atomisp2/Kconfig b/drivers/platform/x86/intel/atomisp2/Kconfig
new file mode 100644 (file)
index 0000000..35dd2be
--- /dev/null
@@ -0,0 +1,43 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Intel x86 Platform Specific Drivers
+#
+
+config INTEL_ATOMISP2_PDX86
+       bool
+
+config INTEL_ATOMISP2_LED
+       tristate "Intel AtomISP v2 camera LED driver"
+       depends on GPIOLIB && LEDS_GPIO
+       select INTEL_ATOMISP2_PDX86
+       help
+         Many Bay Trail and Cherry Trail devices come with a camera attached
+         to Intel's Image Signal Processor. Linux currently does not have a
+         driver for these, so they do not work as a camera. Some of these
+         camera's have a LED which is controlled through a GPIO.
+
+         Some of these devices have a firmware issue where the LED gets turned
+         on at boot. This driver will turn the LED off at boot and also allows
+         controlling the LED (repurposing it) through the sysfs LED interface.
+
+         Which GPIO is attached to the LED is usually not described in the
+         ACPI tables, so this driver contains per-system info about the GPIO
+         inside the driver, this means that this driver only works on systems
+         the driver knows about.
+
+         To compile this driver as a module, choose M here: the module
+         will be called intel_atomisp2_led.
+
+config INTEL_ATOMISP2_PM
+       tristate "Intel AtomISP v2 dummy / power-management driver"
+       depends on PCI && IOSF_MBI && PM
+       depends on !INTEL_ATOMISP
+       select INTEL_ATOMISP2_PDX86
+       help
+         Power-management driver for Intel's Image Signal Processor found on
+         Bay Trail and Cherry Trail devices. This dummy driver's sole purpose
+         is to turn the ISP off (put it in D3) to save power and to allow
+         entering of S0ix modes.
+
+         To compile this driver as a module, choose M here: the module
+         will be called intel_atomisp2_pm.
diff --git a/drivers/platform/x86/intel/atomisp2/Makefile b/drivers/platform/x86/intel/atomisp2/Makefile
new file mode 100644 (file)
index 0000000..96b1e87
--- /dev/null
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Intel x86 Platform Specific Drivers
+#
+
+intel_atomisp2_led-y                   := led.o
+obj-$(CONFIG_INTEL_ATOMISP2_LED)       += intel_atomisp2_led.o
+intel_atomisp2_pm-y                    += pm.o
+obj-$(CONFIG_INTEL_ATOMISP2_PM)                += intel_atomisp2_pm.o
diff --git a/drivers/platform/x86/intel/atomisp2/led.c b/drivers/platform/x86/intel/atomisp2/led.c
new file mode 100644 (file)
index 0000000..5935dfc
--- /dev/null
@@ -0,0 +1,116 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Driver for controlling LEDs for cameras connected to the Intel atomisp2
+ * The main purpose of this driver is to turn off LEDs which are on at boot.
+ *
+ * Copyright (C) 2020 Hans de Goede <hdegoede@redhat.com>
+ */
+
+#include <linux/dmi.h>
+#include <linux/gpio/consumer.h>
+#include <linux/gpio/machine.h>
+#include <linux/leds.h>
+#include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/platform_device.h>
+#include <linux/workqueue.h>
+
+/* This must be leds-gpio as the leds-gpio driver binds to the name */
+#define DEV_NAME               "leds-gpio"
+
+static const struct gpio_led atomisp2_leds[] = {
+       {
+               .name = "atomisp2::camera",
+               .default_state  = LEDS_GPIO_DEFSTATE_OFF,
+       },
+};
+
+static const struct gpio_led_platform_data atomisp2_leds_pdata = {
+       .num_leds       = ARRAY_SIZE(atomisp2_leds),
+       .leds           = atomisp2_leds,
+};
+
+static struct gpiod_lookup_table asus_t100ta_lookup = {
+       .dev_id = DEV_NAME,
+       .table = {
+               GPIO_LOOKUP_IDX("INT33FC:02", 8, NULL, 0, GPIO_ACTIVE_HIGH),
+               { }
+       }
+};
+
+static struct gpiod_lookup_table asus_t100chi_lookup = {
+       .dev_id = DEV_NAME,
+       .table = {
+               GPIO_LOOKUP_IDX("INT33FC:01", 24, NULL, 0, GPIO_ACTIVE_HIGH),
+               { }
+       }
+};
+
+static const struct dmi_system_id atomisp2_led_systems[] __initconst = {
+       {
+               .matches = {
+                       DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+                       DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T100TA"),
+               },
+               .driver_data = &asus_t100ta_lookup,
+       },
+       {
+               .matches = {
+                       DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+                       DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T200TA"),
+               },
+               .driver_data = &asus_t100ta_lookup,
+       },
+       {
+               .matches = {
+                       DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+                       DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T100CHI"),
+               },
+               .driver_data = &asus_t100chi_lookup,
+       },
+       {} /* Terminating entry */
+};
+MODULE_DEVICE_TABLE(dmi, atomisp2_led_systems);
+
+static struct gpiod_lookup_table *gpio_lookup;
+static struct platform_device *pdev;
+
+static int __init atomisp2_led_init(void)
+{
+       const struct dmi_system_id *system;
+
+       system = dmi_first_match(atomisp2_led_systems);
+       if (!system)
+               return -ENODEV;
+
+       gpio_lookup = system->driver_data;
+       gpiod_add_lookup_table(gpio_lookup);
+
+       pdev = platform_device_register_resndata(NULL,
+                                                DEV_NAME, PLATFORM_DEVID_NONE,
+                                                NULL, 0, &atomisp2_leds_pdata,
+                                                sizeof(atomisp2_leds_pdata));
+       if (IS_ERR(pdev))
+               gpiod_remove_lookup_table(gpio_lookup);
+
+       return PTR_ERR_OR_ZERO(pdev);
+}
+
+static void __exit atomisp2_led_cleanup(void)
+{
+       platform_device_unregister(pdev);
+       gpiod_remove_lookup_table(gpio_lookup);
+}
+
+module_init(atomisp2_led_init);
+module_exit(atomisp2_led_cleanup);
+
+/*
+ * The ACPI INIT method from Asus WMI's code on the T100TA and T200TA turns the
+ * LED on (without the WMI interface allowing further control over the LED).
+ * Ensure we are loaded after asus-nb-wmi so that we turn the LED off again.
+ */
+MODULE_SOFTDEP("pre: asus_nb_wmi");
+MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com");
+MODULE_DESCRIPTION("Intel atomisp2 camera LED driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/platform/x86/intel/atomisp2/pm.c b/drivers/platform/x86/intel/atomisp2/pm.c
new file mode 100644 (file)
index 0000000..805fc0d
--- /dev/null
@@ -0,0 +1,143 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Dummy driver for Intel's Image Signal Processor found on Bay Trail
+ * and Cherry Trail devices. The sole purpose of this driver is to allow
+ * the ISP to be put in D3.
+ *
+ * Copyright (C) 2018 Hans de Goede <hdegoede@redhat.com>
+ *
+ * Based on various non upstream patches for ISP support:
+ * Copyright (C) 2010-2017 Intel Corporation. All rights reserved.
+ * Copyright (c) 2010 Silicon Hive www.siliconhive.com.
+ */
+
+#include <linux/delay.h>
+#include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/pci.h>
+#include <linux/pm_runtime.h>
+#include <asm/iosf_mbi.h>
+
+/* PCI configuration regs */
+#define PCI_INTERRUPT_CTRL             0x9c
+
+#define PCI_CSI_CONTROL                        0xe8
+#define PCI_CSI_CONTROL_PORTS_OFF_MASK 0x7
+
+/* IOSF BT_MBI_UNIT_PMC regs */
+#define ISPSSPM0                       0x39
+#define ISPSSPM0_ISPSSC_OFFSET         0
+#define ISPSSPM0_ISPSSC_MASK           0x00000003
+#define ISPSSPM0_ISPSSS_OFFSET         24
+#define ISPSSPM0_ISPSSS_MASK           0x03000000
+#define ISPSSPM0_IUNIT_POWER_ON                0x0
+#define ISPSSPM0_IUNIT_POWER_OFF       0x3
+
+static int isp_set_power(struct pci_dev *dev, bool enable)
+{
+       unsigned long timeout;
+       u32 val = enable ? ISPSSPM0_IUNIT_POWER_ON : ISPSSPM0_IUNIT_POWER_OFF;
+
+       /* Write to ISPSSPM0 bit[1:0] to power on/off the IUNIT */
+       iosf_mbi_modify(BT_MBI_UNIT_PMC, MBI_REG_READ, ISPSSPM0,
+                       val, ISPSSPM0_ISPSSC_MASK);
+
+       /*
+        * There should be no IUNIT access while power-down is
+        * in progress. HW sighting: 4567865.
+        * Wait up to 50 ms for the IUNIT to shut down.
+        * And we do the same for power on.
+        */
+       timeout = jiffies + msecs_to_jiffies(50);
+       do {
+               u32 tmp;
+
+               /* Wait until ISPSSPM0 bit[25:24] shows the right value */
+               iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, ISPSSPM0, &tmp);
+               tmp = (tmp & ISPSSPM0_ISPSSS_MASK) >> ISPSSPM0_ISPSSS_OFFSET;
+               if (tmp == val)
+                       return 0;
+
+               usleep_range(1000, 2000);
+       } while (time_before(jiffies, timeout));
+
+       dev_err(&dev->dev, "IUNIT power-%s timeout.\n", enable ? "on" : "off");
+       return -EBUSY;
+}
+
+static int isp_probe(struct pci_dev *dev, const struct pci_device_id *id)
+{
+       pm_runtime_allow(&dev->dev);
+       pm_runtime_put_sync_suspend(&dev->dev);
+
+       return 0;
+}
+
+static void isp_remove(struct pci_dev *dev)
+{
+       pm_runtime_get_sync(&dev->dev);
+       pm_runtime_forbid(&dev->dev);
+}
+
+static int isp_pci_suspend(struct device *dev)
+{
+       struct pci_dev *pdev = to_pci_dev(dev);
+       u32 val;
+
+       pci_write_config_dword(pdev, PCI_INTERRUPT_CTRL, 0);
+
+       /*
+        * MRFLD IUNIT DPHY is located in an always-power-on island
+        * MRFLD HW design need all CSI ports are disabled before
+        * powering down the IUNIT.
+        */
+       pci_read_config_dword(pdev, PCI_CSI_CONTROL, &val);
+       val |= PCI_CSI_CONTROL_PORTS_OFF_MASK;
+       pci_write_config_dword(pdev, PCI_CSI_CONTROL, val);
+
+       /*
+        * We lose config space access when punit power gates
+        * the ISP. Can't use pci_set_power_state() because
+        * pmcsr won't actually change when we write to it.
+        */
+       pci_save_state(pdev);
+       pdev->current_state = PCI_D3cold;
+       isp_set_power(pdev, false);
+
+       return 0;
+}
+
+static int isp_pci_resume(struct device *dev)
+{
+       struct pci_dev *pdev = to_pci_dev(dev);
+
+       isp_set_power(pdev, true);
+       pdev->current_state = PCI_D0;
+       pci_restore_state(pdev);
+
+       return 0;
+}
+
+static UNIVERSAL_DEV_PM_OPS(isp_pm_ops, isp_pci_suspend,
+                           isp_pci_resume, NULL);
+
+static const struct pci_device_id isp_id_table[] = {
+       { PCI_VDEVICE(INTEL, 0x0f38), },
+       { PCI_VDEVICE(INTEL, 0x22b8), },
+       { 0, }
+};
+MODULE_DEVICE_TABLE(pci, isp_id_table);
+
+static struct pci_driver isp_pci_driver = {
+       .name = "intel_atomisp2_pm",
+       .id_table = isp_id_table,
+       .probe = isp_probe,
+       .remove = isp_remove,
+       .driver.pm = &isp_pm_ops,
+};
+
+module_pci_driver(isp_pci_driver);
+
+MODULE_DESCRIPTION("Intel AtomISP2 dummy / power-management drv (for suspend)");
+MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/platform/x86/intel_atomisp2_led.c b/drivers/platform/x86/intel_atomisp2_led.c
deleted file mode 100644 (file)
index 5935dfc..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Driver for controlling LEDs for cameras connected to the Intel atomisp2
- * The main purpose of this driver is to turn off LEDs which are on at boot.
- *
- * Copyright (C) 2020 Hans de Goede <hdegoede@redhat.com>
- */
-
-#include <linux/dmi.h>
-#include <linux/gpio/consumer.h>
-#include <linux/gpio/machine.h>
-#include <linux/leds.h>
-#include <linux/module.h>
-#include <linux/mod_devicetable.h>
-#include <linux/platform_device.h>
-#include <linux/workqueue.h>
-
-/* This must be leds-gpio as the leds-gpio driver binds to the name */
-#define DEV_NAME               "leds-gpio"
-
-static const struct gpio_led atomisp2_leds[] = {
-       {
-               .name = "atomisp2::camera",
-               .default_state  = LEDS_GPIO_DEFSTATE_OFF,
-       },
-};
-
-static const struct gpio_led_platform_data atomisp2_leds_pdata = {
-       .num_leds       = ARRAY_SIZE(atomisp2_leds),
-       .leds           = atomisp2_leds,
-};
-
-static struct gpiod_lookup_table asus_t100ta_lookup = {
-       .dev_id = DEV_NAME,
-       .table = {
-               GPIO_LOOKUP_IDX("INT33FC:02", 8, NULL, 0, GPIO_ACTIVE_HIGH),
-               { }
-       }
-};
-
-static struct gpiod_lookup_table asus_t100chi_lookup = {
-       .dev_id = DEV_NAME,
-       .table = {
-               GPIO_LOOKUP_IDX("INT33FC:01", 24, NULL, 0, GPIO_ACTIVE_HIGH),
-               { }
-       }
-};
-
-static const struct dmi_system_id atomisp2_led_systems[] __initconst = {
-       {
-               .matches = {
-                       DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
-                       DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T100TA"),
-               },
-               .driver_data = &asus_t100ta_lookup,
-       },
-       {
-               .matches = {
-                       DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
-                       DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T200TA"),
-               },
-               .driver_data = &asus_t100ta_lookup,
-       },
-       {
-               .matches = {
-                       DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
-                       DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T100CHI"),
-               },
-               .driver_data = &asus_t100chi_lookup,
-       },
-       {} /* Terminating entry */
-};
-MODULE_DEVICE_TABLE(dmi, atomisp2_led_systems);
-
-static struct gpiod_lookup_table *gpio_lookup;
-static struct platform_device *pdev;
-
-static int __init atomisp2_led_init(void)
-{
-       const struct dmi_system_id *system;
-
-       system = dmi_first_match(atomisp2_led_systems);
-       if (!system)
-               return -ENODEV;
-
-       gpio_lookup = system->driver_data;
-       gpiod_add_lookup_table(gpio_lookup);
-
-       pdev = platform_device_register_resndata(NULL,
-                                                DEV_NAME, PLATFORM_DEVID_NONE,
-                                                NULL, 0, &atomisp2_leds_pdata,
-                                                sizeof(atomisp2_leds_pdata));
-       if (IS_ERR(pdev))
-               gpiod_remove_lookup_table(gpio_lookup);
-
-       return PTR_ERR_OR_ZERO(pdev);
-}
-
-static void __exit atomisp2_led_cleanup(void)
-{
-       platform_device_unregister(pdev);
-       gpiod_remove_lookup_table(gpio_lookup);
-}
-
-module_init(atomisp2_led_init);
-module_exit(atomisp2_led_cleanup);
-
-/*
- * The ACPI INIT method from Asus WMI's code on the T100TA and T200TA turns the
- * LED on (without the WMI interface allowing further control over the LED).
- * Ensure we are loaded after asus-nb-wmi so that we turn the LED off again.
- */
-MODULE_SOFTDEP("pre: asus_nb_wmi");
-MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com");
-MODULE_DESCRIPTION("Intel atomisp2 camera LED driver");
-MODULE_LICENSE("GPL");
diff --git a/drivers/platform/x86/intel_atomisp2_pm.c b/drivers/platform/x86/intel_atomisp2_pm.c
deleted file mode 100644 (file)
index 805fc0d..0000000
+++ /dev/null
@@ -1,143 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Dummy driver for Intel's Image Signal Processor found on Bay Trail
- * and Cherry Trail devices. The sole purpose of this driver is to allow
- * the ISP to be put in D3.
- *
- * Copyright (C) 2018 Hans de Goede <hdegoede@redhat.com>
- *
- * Based on various non upstream patches for ISP support:
- * Copyright (C) 2010-2017 Intel Corporation. All rights reserved.
- * Copyright (c) 2010 Silicon Hive www.siliconhive.com.
- */
-
-#include <linux/delay.h>
-#include <linux/module.h>
-#include <linux/mod_devicetable.h>
-#include <linux/pci.h>
-#include <linux/pm_runtime.h>
-#include <asm/iosf_mbi.h>
-
-/* PCI configuration regs */
-#define PCI_INTERRUPT_CTRL             0x9c
-
-#define PCI_CSI_CONTROL                        0xe8
-#define PCI_CSI_CONTROL_PORTS_OFF_MASK 0x7
-
-/* IOSF BT_MBI_UNIT_PMC regs */
-#define ISPSSPM0                       0x39
-#define ISPSSPM0_ISPSSC_OFFSET         0
-#define ISPSSPM0_ISPSSC_MASK           0x00000003
-#define ISPSSPM0_ISPSSS_OFFSET         24
-#define ISPSSPM0_ISPSSS_MASK           0x03000000
-#define ISPSSPM0_IUNIT_POWER_ON                0x0
-#define ISPSSPM0_IUNIT_POWER_OFF       0x3
-
-static int isp_set_power(struct pci_dev *dev, bool enable)
-{
-       unsigned long timeout;
-       u32 val = enable ? ISPSSPM0_IUNIT_POWER_ON : ISPSSPM0_IUNIT_POWER_OFF;
-
-       /* Write to ISPSSPM0 bit[1:0] to power on/off the IUNIT */
-       iosf_mbi_modify(BT_MBI_UNIT_PMC, MBI_REG_READ, ISPSSPM0,
-                       val, ISPSSPM0_ISPSSC_MASK);
-
-       /*
-        * There should be no IUNIT access while power-down is
-        * in progress. HW sighting: 4567865.
-        * Wait up to 50 ms for the IUNIT to shut down.
-        * And we do the same for power on.
-        */
-       timeout = jiffies + msecs_to_jiffies(50);
-       do {
-               u32 tmp;
-
-               /* Wait until ISPSSPM0 bit[25:24] shows the right value */
-               iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, ISPSSPM0, &tmp);
-               tmp = (tmp & ISPSSPM0_ISPSSS_MASK) >> ISPSSPM0_ISPSSS_OFFSET;
-               if (tmp == val)
-                       return 0;
-
-               usleep_range(1000, 2000);
-       } while (time_before(jiffies, timeout));
-
-       dev_err(&dev->dev, "IUNIT power-%s timeout.\n", enable ? "on" : "off");
-       return -EBUSY;
-}
-
-static int isp_probe(struct pci_dev *dev, const struct pci_device_id *id)
-{
-       pm_runtime_allow(&dev->dev);
-       pm_runtime_put_sync_suspend(&dev->dev);
-
-       return 0;
-}
-
-static void isp_remove(struct pci_dev *dev)
-{
-       pm_runtime_get_sync(&dev->dev);
-       pm_runtime_forbid(&dev->dev);
-}
-
-static int isp_pci_suspend(struct device *dev)
-{
-       struct pci_dev *pdev = to_pci_dev(dev);
-       u32 val;
-
-       pci_write_config_dword(pdev, PCI_INTERRUPT_CTRL, 0);
-
-       /*
-        * MRFLD IUNIT DPHY is located in an always-power-on island
-        * MRFLD HW design need all CSI ports are disabled before
-        * powering down the IUNIT.
-        */
-       pci_read_config_dword(pdev, PCI_CSI_CONTROL, &val);
-       val |= PCI_CSI_CONTROL_PORTS_OFF_MASK;
-       pci_write_config_dword(pdev, PCI_CSI_CONTROL, val);
-
-       /*
-        * We lose config space access when punit power gates
-        * the ISP. Can't use pci_set_power_state() because
-        * pmcsr won't actually change when we write to it.
-        */
-       pci_save_state(pdev);
-       pdev->current_state = PCI_D3cold;
-       isp_set_power(pdev, false);
-
-       return 0;
-}
-
-static int isp_pci_resume(struct device *dev)
-{
-       struct pci_dev *pdev = to_pci_dev(dev);
-
-       isp_set_power(pdev, true);
-       pdev->current_state = PCI_D0;
-       pci_restore_state(pdev);
-
-       return 0;
-}
-
-static UNIVERSAL_DEV_PM_OPS(isp_pm_ops, isp_pci_suspend,
-                           isp_pci_resume, NULL);
-
-static const struct pci_device_id isp_id_table[] = {
-       { PCI_VDEVICE(INTEL, 0x0f38), },
-       { PCI_VDEVICE(INTEL, 0x22b8), },
-       { 0, }
-};
-MODULE_DEVICE_TABLE(pci, isp_id_table);
-
-static struct pci_driver isp_pci_driver = {
-       .name = "intel_atomisp2_pm",
-       .id_table = isp_id_table,
-       .probe = isp_probe,
-       .remove = isp_remove,
-       .driver.pm = &isp_pm_ops,
-};
-
-module_pci_driver(isp_pci_driver);
-
-MODULE_DESCRIPTION("Intel AtomISP2 dummy / power-management drv (for suspend)");
-MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>");
-MODULE_LICENSE("GPL v2");