aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/intel_atomisp2_pm.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-11-01 11:42:21 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-11-01 11:42:21 -0400
commiteb7046e9bf466cebfcfbcdf640e41d9e3a80086c (patch)
tree7d998f56e306de4c1a78355f219e38b75cfe3866 /drivers/platform/x86/intel_atomisp2_pm.c
parent5b7449810ae6d652629c550d3974c8453836d229 (diff)
parent3b692c55e58d06ba9b17c66784cab5a95ba5be9b (diff)
Merge tag 'platform-drivers-x86-v4.20-1' of git://git.infradead.org/linux-platform-drivers-x86
Pull x86 platform driver updates from Darren Hart: - Move the Dell dcdbas and dell_rbu drivers into platform/drivers/x86 as they are closely coupled with other drivers in this location. - Improve _init* usage for acerhdf and fix some usage issues with messages and module parameters. - Simplify asus-wmi by calling ACPI/WMI methods directly, eliminating workqueue overhead, eliminate double reporting of keyboard backlight. - Fix wake from USB failure on Bay Trail devices (intel_int0002_vgpio). - Notify intel_telemetry users when IPC1 device is not enabled. - Update various drivers with new laptop model IDs. - Update several intel drivers to use SPDX identifers and order headers alphabetically. * tag 'platform-drivers-x86-v4.20-1' of git://git.infradead.org/linux-platform-drivers-x86: (64 commits) HID: asus: only support backlight when it's not driven by WMI platform/x86: asus-wmi: export function for evaluating WMI methods platform/x86: asus-wmi: Only notify kbd LED hw_change by fn-key pressed platform/x86: wmi: declare device_type structure as constant platform/x86: ideapad: Add Y530-15ICH to no_hw_rfkill platform/x86: Add Intel AtomISP2 dummy / power-management driver platform/x86: touchscreen_dmi: Add min-x and min-y settings for various models platform/x86: touchscreen_dmi: Add info for the Onda V80 Plus v3 tablet platform/x86: touchscreen_dmi: Add info for the Trekstor Primetab T13B tablet platform/x86: intel_telemetry: Get rid of custom macro platform/x86: intel_telemetry: report debugfs failure MAINTAINERS: intel_telemetry: Update maintainers info platform/x86: Add LG Gram laptop special features driver platform/x86: asus-wmi: Simplify the keyboard brightness updating process platform/x86: touchscreen_dmi: Add info for the Trekstor Primebook C11 convertible platform/x86: mlx-platform: Properly use mlxplat_mlxcpld_msn201x_items MAINTAINERS: intel_pmc_core: Update MAINTAINERS firmware: dcdbas: include linux/io.h platform/x86: intel-wmi-thunderbolt: Add dynamic debugging platform/x86: intel-wmi-thunderbolt: Convert to use SPDX identifier ...
Diffstat (limited to 'drivers/platform/x86/intel_atomisp2_pm.c')
-rw-r--r--drivers/platform/x86/intel_atomisp2_pm.c119
1 files changed, 119 insertions, 0 deletions
diff --git a/drivers/platform/x86/intel_atomisp2_pm.c b/drivers/platform/x86/intel_atomisp2_pm.c
new file mode 100644
index 000000000000..9371603a0ac9
--- /dev/null
+++ b/drivers/platform/x86/intel_atomisp2_pm.c
@@ -0,0 +1,119 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Dummy driver for Intel's Image Signal Processor found on Bay and Cherry
4 * Trail devices. The sole purpose of this driver is to allow the ISP to
5 * be put in D3.
6 *
7 * Copyright (C) 2018 Hans de Goede <hdegoede@redhat.com>
8 *
9 * Based on various non upstream patches for ISP support:
10 * Copyright (C) 2010-2017 Intel Corporation. All rights reserved.
11 * Copyright (c) 2010 Silicon Hive www.siliconhive.com.
12 */
13
14#include <linux/delay.h>
15#include <linux/module.h>
16#include <linux/mod_devicetable.h>
17#include <linux/pci.h>
18#include <linux/pm_runtime.h>
19#include <asm/iosf_mbi.h>
20
21/* PCI configuration regs */
22#define PCI_INTERRUPT_CTRL 0x9c
23
24#define PCI_CSI_CONTROL 0xe8
25#define PCI_CSI_CONTROL_PORTS_OFF_MASK 0x7
26
27/* IOSF BT_MBI_UNIT_PMC regs */
28#define ISPSSPM0 0x39
29#define ISPSSPM0_ISPSSC_OFFSET 0
30#define ISPSSPM0_ISPSSC_MASK 0x00000003
31#define ISPSSPM0_ISPSSS_OFFSET 24
32#define ISPSSPM0_ISPSSS_MASK 0x03000000
33#define ISPSSPM0_IUNIT_POWER_ON 0x0
34#define ISPSSPM0_IUNIT_POWER_OFF 0x3
35
36static int isp_probe(struct pci_dev *dev, const struct pci_device_id *id)
37{
38 unsigned long timeout;
39 u32 val;
40
41 pci_write_config_dword(dev, PCI_INTERRUPT_CTRL, 0);
42
43 /*
44 * MRFLD IUNIT DPHY is located in an always-power-on island
45 * MRFLD HW design need all CSI ports are disabled before
46 * powering down the IUNIT.
47 */
48 pci_read_config_dword(dev, PCI_CSI_CONTROL, &val);
49 val |= PCI_CSI_CONTROL_PORTS_OFF_MASK;
50 pci_write_config_dword(dev, PCI_CSI_CONTROL, val);
51
52 /* Write 0x3 to ISPSSPM0 bit[1:0] to power off the IUNIT */
53 iosf_mbi_modify(BT_MBI_UNIT_PMC, MBI_REG_READ, ISPSSPM0,
54 ISPSSPM0_IUNIT_POWER_OFF, ISPSSPM0_ISPSSC_MASK);
55
56 /*
57 * There should be no IUNIT access while power-down is
58 * in progress HW sighting: 4567865
59 * Wait up to 50 ms for the IUNIT to shut down.
60 */
61 timeout = jiffies + msecs_to_jiffies(50);
62 while (1) {
63 /* Wait until ISPSSPM0 bit[25:24] shows 0x3 */
64 iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, ISPSSPM0, &val);
65 val = (val & ISPSSPM0_ISPSSS_MASK) >> ISPSSPM0_ISPSSS_OFFSET;
66 if (val == ISPSSPM0_IUNIT_POWER_OFF)
67 break;
68
69 if (time_after(jiffies, timeout)) {
70 dev_err(&dev->dev, "IUNIT power-off timeout.\n");
71 return -EBUSY;
72 }
73 usleep_range(1000, 2000);
74 }
75
76 pm_runtime_allow(&dev->dev);
77 pm_runtime_put_sync_suspend(&dev->dev);
78
79 return 0;
80}
81
82static void isp_remove(struct pci_dev *dev)
83{
84 pm_runtime_get_sync(&dev->dev);
85 pm_runtime_forbid(&dev->dev);
86}
87
88static int isp_pci_suspend(struct device *dev)
89{
90 return 0;
91}
92
93static int isp_pci_resume(struct device *dev)
94{
95 return 0;
96}
97
98static UNIVERSAL_DEV_PM_OPS(isp_pm_ops, isp_pci_suspend,
99 isp_pci_resume, NULL);
100
101static const struct pci_device_id isp_id_table[] = {
102 { PCI_VDEVICE(INTEL, 0x22b8), },
103 { 0, }
104};
105MODULE_DEVICE_TABLE(pci, isp_id_table);
106
107static struct pci_driver isp_pci_driver = {
108 .name = "intel_atomisp2_pm",
109 .id_table = isp_id_table,
110 .probe = isp_probe,
111 .remove = isp_remove,
112 .driver.pm = &isp_pm_ops,
113};
114
115module_pci_driver(isp_pci_driver);
116
117MODULE_DESCRIPTION("Intel AtomISP2 dummy / power-management drv (for suspend)");
118MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>");
119MODULE_LICENSE("GPL v2");