aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-05-01 17:13:28 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-05-01 17:13:28 -0400
commit08be881064da126b8df4b96b0b3e2e307969a4a1 (patch)
tree0b51c465a0700ffc28d5083fa714285e5b894782
parent0e285e90887bcb248178d55960e1276188c657c9 (diff)
parent52e70c8af7e5d04e3fe431066f0530a17a8147c2 (diff)
Merge tag 'acpi-4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull ACPI updates from Rafael Wysocki: "These are some device enumeration code changes, updates of the AC and battery drivers to help them avoid attaching to devices that cannot be handled by them, new operation region driver for the Intel CHT Whiskey Cove PMIC, new sysfs entries for CPPC performance capabilities, a new _REV quirk blacklist entry and a couple of assorted minor fixes and cleanups. Specifics: - Update the core device enumeration code to make it more internally consistent and robust and drop the force_remove sysfs attribute that could be used to tell it to ignore errors on device hot-removal which was dangerous in general and no real and still relevant use cases for it could be found (Rafael Wysocki, Michal Hocko). - Make the core device enumeration code use _PXM to associate platform devices created by it with specific NUMA nodes (Shanker Donthineni). - Extend the CPPC library by adding more sysfs entries for performance capabilities to it and making it use the lowest nonlinear performance parameter (Prashanth Prakash). - Make the CPU online more consistent with CPU initialization in the ACPI processor driver (Prashanth Prakash). - Update the AC and battery drivers to help them avoid attaching to devices that cannot be handled by them and update the axp288_charger power supply driver to work correctly on ACPI systems without the INT3496 device (Hans de Goede). - Add an ACPI operation region driver for the Intel CHT Whiskey Cove PMIC and update the xpower operation region driver to work without IIO which isn't really necessary for it to work (Hans de Goede). - Add a new entry for Dell Inspiron 7537 to the _REV quirk blacklist (Kai Heng Feng). - Make the code in the ACPI video driver easier to follow by adding symbols and comments to it (Dmitry Frank). - Update ACPI documentation and drop a function that has no users from the tables-handling code (Cao jin, Baoquan He)" * tag 'acpi-4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: ACPI / PMIC: Stop xpower OPRegion handler relying on IIO ACPI / PMIC: Add opregion driver for Intel CHT Whiskey Cove PMIC ACPI / scan: Avoid enumerating devices more than once ACPI / scan: Apply default enumeration to devices with ACPI drivers power: supply: axp288_charger: Only wait for INT3496 device if present ACPI / AC: Add a blacklist with PMIC ACPI HIDs with a native charger driver ACPI / battery: Add a blacklist with PMIC ACPI HIDs with a native battery driver ACPI / battery: Fix acpi_battery_exit on acpi_battery_init_async errors ACPI / utils: Add new acpi_dev_present helper ACPI / video: add comments about subtle cases ACPI / video: get rid of magic numbers and use enum instead ACPI / doc: linuxized-acpica.txt: fix typos ACPI / blacklist: add _REV quirk for Dell Inspiron 7537 ACPI / tables: Drop acpi_parse_entries() which is not used ACPI / CPPC: add sysfs entries for CPPC perf capabilities ACPI / CPPC: Read lowest nonlinear perf in cppc_get_perf_caps() ACPI / platform: Update platform device NUMA node based on _PXM method ACPI / Processor: Drop setup_max_cpus check from acpi_processor_add() ACPI / scan: Drop support for force_remove
-rw-r--r--Documentation/ABI/obsolete/sysfs-firmware-acpi8
-rw-r--r--Documentation/ABI/testing/sysfs-firmware-acpi10
-rw-r--r--Documentation/acpi/linuxized-acpica.txt10
-rw-r--r--drivers/acpi/Kconfig8
-rw-r--r--drivers/acpi/Makefile1
-rw-r--r--drivers/acpi/ac.c20
-rw-r--r--drivers/acpi/acpi_platform.c5
-rw-r--r--drivers/acpi/acpi_processor.c5
-rw-r--r--drivers/acpi/acpi_video.c157
-rw-r--r--drivers/acpi/battery.c22
-rw-r--r--drivers/acpi/blacklist.c8
-rw-r--r--drivers/acpi/cppc_acpi.c80
-rw-r--r--drivers/acpi/internal.h2
-rw-r--r--drivers/acpi/pmic/intel_pmic_chtwc.c280
-rw-r--r--drivers/acpi/pmic/intel_pmic_xpower.c21
-rw-r--r--drivers/acpi/scan.c24
-rw-r--r--drivers/acpi/sysfs.c9
-rw-r--r--drivers/acpi/tables.c16
-rw-r--r--drivers/acpi/utils.c66
-rw-r--r--drivers/power/supply/axp288_charger.c28
-rw-r--r--include/acpi/acpi_bus.h1
-rw-r--r--include/acpi/cppc_acpi.h3
-rw-r--r--include/linux/acpi.h9
23 files changed, 617 insertions, 176 deletions
diff --git a/Documentation/ABI/obsolete/sysfs-firmware-acpi b/Documentation/ABI/obsolete/sysfs-firmware-acpi
new file mode 100644
index 000000000000..6715a71bec3d
--- /dev/null
+++ b/Documentation/ABI/obsolete/sysfs-firmware-acpi
@@ -0,0 +1,8 @@
1What: /sys/firmware/acpi/hotplug/force_remove
2Date: Mar 2017
3Contact: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
4Description:
5 Since the force_remove is inherently broken and dangerous to
6 use for some hotplugable resources like memory (because ignoring
7 the offline failure might lead to memory corruption and crashes)
8 enabling this knob is not safe and thus unsupported.
diff --git a/Documentation/ABI/testing/sysfs-firmware-acpi b/Documentation/ABI/testing/sysfs-firmware-acpi
index c7fc72d4495c..613f42a9d5cd 100644
--- a/Documentation/ABI/testing/sysfs-firmware-acpi
+++ b/Documentation/ABI/testing/sysfs-firmware-acpi
@@ -44,16 +44,6 @@ Description:
44 or 0 (unset). Attempts to write any other values to it will 44 or 0 (unset). Attempts to write any other values to it will
45 cause -EINVAL to be returned. 45 cause -EINVAL to be returned.
46 46
47What: /sys/firmware/acpi/hotplug/force_remove
48Date: May 2013
49Contact: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
50Description:
51 The number in this file (0 or 1) determines whether (1) or not
52 (0) the ACPI subsystem will allow devices to be hot-removed even
53 if they cannot be put offline gracefully (from the kernel's
54 viewpoint). That number can be changed by writing a boolean
55 value to this file.
56
57What: /sys/firmware/acpi/interrupts/ 47What: /sys/firmware/acpi/interrupts/
58Date: February 2008 48Date: February 2008
59Contact: Len Brown <lenb@kernel.org> 49Contact: Len Brown <lenb@kernel.org>
diff --git a/Documentation/acpi/linuxized-acpica.txt b/Documentation/acpi/linuxized-acpica.txt
index defe2eec5331..3ad7b0dfb083 100644
--- a/Documentation/acpi/linuxized-acpica.txt
+++ b/Documentation/acpi/linuxized-acpica.txt
@@ -24,7 +24,7 @@ upstream.
24 The homepage of ACPICA project is: www.acpica.org, it is maintained and 24 The homepage of ACPICA project is: www.acpica.org, it is maintained and
25 supported by Intel Corporation. 25 supported by Intel Corporation.
26 26
27 The following figure depicts the Linux ACPI subystem where the ACPICA 27 The following figure depicts the Linux ACPI subsystem where the ACPICA
28 adaptation is included: 28 adaptation is included:
29 29
30 +---------------------------------------------------------+ 30 +---------------------------------------------------------+
@@ -110,7 +110,7 @@ upstream.
110 Linux patches. The patches generated by this process are referred to as 110 Linux patches. The patches generated by this process are referred to as
111 "linuxized ACPICA patches". The release process is carried out on a local 111 "linuxized ACPICA patches". The release process is carried out on a local
112 copy the ACPICA git repository. Each commit in the monthly release is 112 copy the ACPICA git repository. Each commit in the monthly release is
113 converted into a linuxized ACPICA patch. Together, they form the montly 113 converted into a linuxized ACPICA patch. Together, they form the monthly
114 ACPICA release patchset for the Linux ACPI community. This process is 114 ACPICA release patchset for the Linux ACPI community. This process is
115 illustrated in the following figure: 115 illustrated in the following figure:
116 116
@@ -165,7 +165,7 @@ upstream.
165 <http://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git>. 165 <http://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git>.
166 166
167 Before the linuxized ACPICA patches are sent to the Linux ACPI community 167 Before the linuxized ACPICA patches are sent to the Linux ACPI community
168 for review, there is a quality ensurance build test process to reduce 168 for review, there is a quality assurance build test process to reduce
169 porting issues. Currently this build process only takes care of the 169 porting issues. Currently this build process only takes care of the
170 following kernel configuration options: 170 following kernel configuration options:
171 CONFIG_ACPI/CONFIG_ACPI_DEBUG/CONFIG_ACPI_DEBUGGER 171 CONFIG_ACPI/CONFIG_ACPI_DEBUG/CONFIG_ACPI_DEBUGGER
@@ -195,12 +195,12 @@ upstream.
195 release utilities (please refer to Section 4 below for the details). 195 release utilities (please refer to Section 4 below for the details).
196 3. Linux specific features - Sometimes it's impossible to use the 196 3. Linux specific features - Sometimes it's impossible to use the
197 current ACPICA APIs to implement features required by the Linux kernel, 197 current ACPICA APIs to implement features required by the Linux kernel,
198 so Linux developers occasionaly have to change ACPICA code directly. 198 so Linux developers occasionally have to change ACPICA code directly.
199 Those changes may not be acceptable by ACPICA upstream and in such cases 199 Those changes may not be acceptable by ACPICA upstream and in such cases
200 they are left as committed ACPICA divergences unless the ACPICA side can 200 they are left as committed ACPICA divergences unless the ACPICA side can
201 implement new mechanisms as replacements for them. 201 implement new mechanisms as replacements for them.
202 4. ACPICA release fixups - ACPICA only tests commits using a set of the 202 4. ACPICA release fixups - ACPICA only tests commits using a set of the
203 user space simulation utilies, thus the linuxized ACPICA patches may 203 user space simulation utilities, thus the linuxized ACPICA patches may
204 break the Linux kernel, leaving us build/boot failures. In order to 204 break the Linux kernel, leaving us build/boot failures. In order to
205 avoid breaking Linux bisection, fixes are applied directly to the 205 avoid breaking Linux bisection, fixes are applied directly to the
206 linuxized ACPICA patches during the release process. When the release 206 linuxized ACPICA patches during the release process. When the release
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index c6db511b5f73..de3b8fce5164 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -505,7 +505,7 @@ config CRC_PMIC_OPREGION
505 505
506config XPOWER_PMIC_OPREGION 506config XPOWER_PMIC_OPREGION
507 bool "ACPI operation region support for XPower AXP288 PMIC" 507 bool "ACPI operation region support for XPower AXP288 PMIC"
508 depends on AXP288_ADC = y 508 depends on MFD_AXP20X_I2C
509 help 509 help
510 This config adds ACPI operation region support for XPower AXP288 PMIC. 510 This config adds ACPI operation region support for XPower AXP288 PMIC.
511 511
@@ -515,6 +515,12 @@ config BXT_WC_PMIC_OPREGION
515 help 515 help
516 This config adds ACPI operation region support for BXT WhiskeyCove PMIC. 516 This config adds ACPI operation region support for BXT WhiskeyCove PMIC.
517 517
518config CHT_WC_PMIC_OPREGION
519 bool "ACPI operation region support for CHT Whiskey Cove PMIC"
520 depends on INTEL_SOC_PMIC_CHTWC
521 help
522 This config adds ACPI operation region support for CHT Whiskey Cove PMIC.
523
518endif 524endif
519 525
520config ACPI_CONFIGFS 526config ACPI_CONFIGFS
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index d94f92f88ca1..d78065cc9324 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -101,6 +101,7 @@ obj-$(CONFIG_PMIC_OPREGION) += pmic/intel_pmic.o
101obj-$(CONFIG_CRC_PMIC_OPREGION) += pmic/intel_pmic_crc.o 101obj-$(CONFIG_CRC_PMIC_OPREGION) += pmic/intel_pmic_crc.o
102obj-$(CONFIG_XPOWER_PMIC_OPREGION) += pmic/intel_pmic_xpower.o 102obj-$(CONFIG_XPOWER_PMIC_OPREGION) += pmic/intel_pmic_xpower.o
103obj-$(CONFIG_BXT_WC_PMIC_OPREGION) += pmic/intel_pmic_bxtwc.o 103obj-$(CONFIG_BXT_WC_PMIC_OPREGION) += pmic/intel_pmic_bxtwc.o
104obj-$(CONFIG_CHT_WC_PMIC_OPREGION) += pmic/intel_pmic_chtwc.o
104 105
105obj-$(CONFIG_ACPI_CONFIGFS) += acpi_configfs.o 106obj-$(CONFIG_ACPI_CONFIGFS) += acpi_configfs.o
106 107
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index f71b756b05c4..8f52483219ba 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -57,12 +57,23 @@ static int acpi_ac_add(struct acpi_device *device);
57static int acpi_ac_remove(struct acpi_device *device); 57static int acpi_ac_remove(struct acpi_device *device);
58static void acpi_ac_notify(struct acpi_device *device, u32 event); 58static void acpi_ac_notify(struct acpi_device *device, u32 event);
59 59
60struct acpi_ac_bl {
61 const char *hid;
62 int hrv;
63};
64
60static const struct acpi_device_id ac_device_ids[] = { 65static const struct acpi_device_id ac_device_ids[] = {
61 {"ACPI0003", 0}, 66 {"ACPI0003", 0},
62 {"", 0}, 67 {"", 0},
63}; 68};
64MODULE_DEVICE_TABLE(acpi, ac_device_ids); 69MODULE_DEVICE_TABLE(acpi, ac_device_ids);
65 70
71/* Lists of PMIC ACPI HIDs with an (often better) native charger driver */
72static const struct acpi_ac_bl acpi_ac_blacklist[] = {
73 { "INT33F4", -1 }, /* X-Powers AXP288 PMIC */
74 { "INT34D3", 3 }, /* Intel Cherrytrail Whiskey Cove PMIC */
75};
76
66#ifdef CONFIG_PM_SLEEP 77#ifdef CONFIG_PM_SLEEP
67static int acpi_ac_resume(struct device *dev); 78static int acpi_ac_resume(struct device *dev);
68#endif 79#endif
@@ -424,11 +435,20 @@ static int acpi_ac_remove(struct acpi_device *device)
424 435
425static int __init acpi_ac_init(void) 436static int __init acpi_ac_init(void)
426{ 437{
438 unsigned int i;
427 int result; 439 int result;
428 440
429 if (acpi_disabled) 441 if (acpi_disabled)
430 return -ENODEV; 442 return -ENODEV;
431 443
444 for (i = 0; i < ARRAY_SIZE(acpi_ac_blacklist); i++)
445 if (acpi_dev_present(acpi_ac_blacklist[i].hid, "1",
446 acpi_ac_blacklist[i].hrv)) {
447 pr_info(PREFIX "AC: found native %s PMIC, not loading\n",
448 acpi_ac_blacklist[i].hid);
449 return -ENODEV;
450 }
451
432#ifdef CONFIG_ACPI_PROCFS_POWER 452#ifdef CONFIG_ACPI_PROCFS_POWER
433 acpi_ac_dir = acpi_lock_ac_dir(); 453 acpi_ac_dir = acpi_lock_ac_dir();
434 if (!acpi_ac_dir) 454 if (!acpi_ac_dir)
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index 03250e1f1103..88cd949003f3 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -121,11 +121,14 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
121 if (IS_ERR(pdev)) 121 if (IS_ERR(pdev))
122 dev_err(&adev->dev, "platform device creation failed: %ld\n", 122 dev_err(&adev->dev, "platform device creation failed: %ld\n",
123 PTR_ERR(pdev)); 123 PTR_ERR(pdev));
124 else 124 else {
125 set_dev_node(&pdev->dev, acpi_get_node(adev->handle));
125 dev_dbg(&adev->dev, "created platform device %s\n", 126 dev_dbg(&adev->dev, "created platform device %s\n",
126 dev_name(&pdev->dev)); 127 dev_name(&pdev->dev));
128 }
127 129
128 kfree(resources); 130 kfree(resources);
131
129 return pdev; 132 return pdev;
130} 133}
131EXPORT_SYMBOL_GPL(acpi_create_platform_device); 134EXPORT_SYMBOL_GPL(acpi_create_platform_device);
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index 0143135b3abe..f098e25b6b41 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -388,11 +388,6 @@ static int acpi_processor_add(struct acpi_device *device,
388 if (result) /* Processor is not physically present or unavailable */ 388 if (result) /* Processor is not physically present or unavailable */
389 return 0; 389 return 0;
390 390
391#ifdef CONFIG_SMP
392 if (pr->id >= setup_max_cpus && pr->id != 0)
393 return 0;
394#endif
395
396 BUG_ON(pr->id >= nr_cpu_ids); 391 BUG_ON(pr->id >= nr_cpu_ids);
397 392
398 /* 393 /*
diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index d00bc0ef87a6..e88fe3632dd6 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -73,6 +73,10 @@ module_param(report_key_events, int, 0644);
73MODULE_PARM_DESC(report_key_events, 73MODULE_PARM_DESC(report_key_events,
74 "0: none, 1: output changes, 2: brightness changes, 3: all"); 74 "0: none, 1: output changes, 2: brightness changes, 3: all");
75 75
76/*
77 * Whether the struct acpi_video_device_attrib::device_id_scheme bit should be
78 * assumed even if not actually set.
79 */
76static bool device_id_scheme = false; 80static bool device_id_scheme = false;
77module_param(device_id_scheme, bool, 0444); 81module_param(device_id_scheme, bool, 0444);
78 82
@@ -88,6 +92,18 @@ static int acpi_video_bus_remove(struct acpi_device *device);
88static void acpi_video_bus_notify(struct acpi_device *device, u32 event); 92static void acpi_video_bus_notify(struct acpi_device *device, u32 event);
89void acpi_video_detect_exit(void); 93void acpi_video_detect_exit(void);
90 94
95/*
96 * Indices in the _BCL method response: the first two items are special,
97 * the rest are all supported levels.
98 *
99 * See page 575 of the ACPI spec 3.0
100 */
101enum acpi_video_level_idx {
102 ACPI_VIDEO_AC_LEVEL, /* level when machine has full power */
103 ACPI_VIDEO_BATTERY_LEVEL, /* level when machine is on batteries */
104 ACPI_VIDEO_FIRST_LEVEL, /* actual supported levels begin here */
105};
106
91static const struct acpi_device_id video_device_ids[] = { 107static const struct acpi_device_id video_device_ids[] = {
92 {ACPI_VIDEO_HID, 0}, 108 {ACPI_VIDEO_HID, 0},
93 {"", 0}, 109 {"", 0},
@@ -132,7 +148,15 @@ struct acpi_video_device_attrib {
132 the VGA device. */ 148 the VGA device. */
133 u32 pipe_id:3; /* For VGA multiple-head devices. */ 149 u32 pipe_id:3; /* For VGA multiple-head devices. */
134 u32 reserved:10; /* Must be 0 */ 150 u32 reserved:10; /* Must be 0 */
135 u32 device_id_scheme:1; /* Device ID Scheme */ 151
152 /*
153 * The device ID might not actually follow the scheme described by this
154 * struct acpi_video_device_attrib. If it does, then this bit
155 * device_id_scheme is set; otherwise, other fields should be ignored.
156 *
157 * (but also see the global flag device_id_scheme)
158 */
159 u32 device_id_scheme:1;
136}; 160};
137 161
138struct acpi_video_enumerated_device { 162struct acpi_video_enumerated_device {
@@ -217,20 +241,16 @@ static int acpi_video_get_brightness(struct backlight_device *bd)
217 241
218 if (acpi_video_device_lcd_get_level_current(vd, &cur_level, false)) 242 if (acpi_video_device_lcd_get_level_current(vd, &cur_level, false))
219 return -EINVAL; 243 return -EINVAL;
220 for (i = 2; i < vd->brightness->count; i++) { 244 for (i = ACPI_VIDEO_FIRST_LEVEL; i < vd->brightness->count; i++) {
221 if (vd->brightness->levels[i] == cur_level) 245 if (vd->brightness->levels[i] == cur_level)
222 /* 246 return i - ACPI_VIDEO_FIRST_LEVEL;
223 * The first two entries are special - see page 575
224 * of the ACPI spec 3.0
225 */
226 return i - 2;
227 } 247 }
228 return 0; 248 return 0;
229} 249}
230 250
231static int acpi_video_set_brightness(struct backlight_device *bd) 251static int acpi_video_set_brightness(struct backlight_device *bd)
232{ 252{
233 int request_level = bd->props.brightness + 2; 253 int request_level = bd->props.brightness + ACPI_VIDEO_FIRST_LEVEL;
234 struct acpi_video_device *vd = bl_get_data(bd); 254 struct acpi_video_device *vd = bl_get_data(bd);
235 255
236 cancel_delayed_work(&vd->switch_brightness_work); 256 cancel_delayed_work(&vd->switch_brightness_work);
@@ -244,18 +264,18 @@ static const struct backlight_ops acpi_backlight_ops = {
244}; 264};
245 265
246/* thermal cooling device callbacks */ 266/* thermal cooling device callbacks */
247static int video_get_max_state(struct thermal_cooling_device *cooling_dev, unsigned 267static int video_get_max_state(struct thermal_cooling_device *cooling_dev,
248 long *state) 268 unsigned long *state)
249{ 269{
250 struct acpi_device *device = cooling_dev->devdata; 270 struct acpi_device *device = cooling_dev->devdata;
251 struct acpi_video_device *video = acpi_driver_data(device); 271 struct acpi_video_device *video = acpi_driver_data(device);
252 272
253 *state = video->brightness->count - 3; 273 *state = video->brightness->count - ACPI_VIDEO_FIRST_LEVEL - 1;
254 return 0; 274 return 0;
255} 275}
256 276
257static int video_get_cur_state(struct thermal_cooling_device *cooling_dev, unsigned 277static int video_get_cur_state(struct thermal_cooling_device *cooling_dev,
258 long *state) 278 unsigned long *state)
259{ 279{
260 struct acpi_device *device = cooling_dev->devdata; 280 struct acpi_device *device = cooling_dev->devdata;
261 struct acpi_video_device *video = acpi_driver_data(device); 281 struct acpi_video_device *video = acpi_driver_data(device);
@@ -264,7 +284,8 @@ static int video_get_cur_state(struct thermal_cooling_device *cooling_dev, unsig
264 284
265 if (acpi_video_device_lcd_get_level_current(video, &level, false)) 285 if (acpi_video_device_lcd_get_level_current(video, &level, false))
266 return -EINVAL; 286 return -EINVAL;
267 for (offset = 2; offset < video->brightness->count; offset++) 287 for (offset = ACPI_VIDEO_FIRST_LEVEL; offset < video->brightness->count;
288 offset++)
268 if (level == video->brightness->levels[offset]) { 289 if (level == video->brightness->levels[offset]) {
269 *state = video->brightness->count - offset - 1; 290 *state = video->brightness->count - offset - 1;
270 return 0; 291 return 0;
@@ -280,7 +301,7 @@ video_set_cur_state(struct thermal_cooling_device *cooling_dev, unsigned long st
280 struct acpi_video_device *video = acpi_driver_data(device); 301 struct acpi_video_device *video = acpi_driver_data(device);
281 int level; 302 int level;
282 303
283 if (state >= video->brightness->count - 2) 304 if (state >= video->brightness->count - ACPI_VIDEO_FIRST_LEVEL)
284 return -EINVAL; 305 return -EINVAL;
285 306
286 state = video->brightness->count - state; 307 state = video->brightness->count - state;
@@ -345,10 +366,12 @@ acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
345 } 366 }
346 367
347 device->brightness->curr = level; 368 device->brightness->curr = level;
348 for (state = 2; state < device->brightness->count; state++) 369 for (state = ACPI_VIDEO_FIRST_LEVEL; state < device->brightness->count;
370 state++)
349 if (level == device->brightness->levels[state]) { 371 if (level == device->brightness->levels[state]) {
350 if (device->backlight) 372 if (device->backlight)
351 device->backlight->props.brightness = state - 2; 373 device->backlight->props.brightness =
374 state - ACPI_VIDEO_FIRST_LEVEL;
352 return 0; 375 return 0;
353 } 376 }
354 377
@@ -530,14 +553,16 @@ acpi_video_bqc_value_to_level(struct acpi_video_device *device,
530 553
531 if (device->brightness->flags._BQC_use_index) { 554 if (device->brightness->flags._BQC_use_index) {
532 /* 555 /*
533 * _BQC returns an index that doesn't account for 556 * _BQC returns an index that doesn't account for the first 2
534 * the first 2 items with special meaning, so we need 557 * items with special meaning (see enum acpi_video_level_idx),
535 * to compensate for that by offsetting ourselves 558 * so we need to compensate for that by offsetting ourselves
536 */ 559 */
537 if (device->brightness->flags._BCL_reversed) 560 if (device->brightness->flags._BCL_reversed)
538 bqc_value = device->brightness->count - 3 - bqc_value; 561 bqc_value = device->brightness->count -
562 ACPI_VIDEO_FIRST_LEVEL - 1 - bqc_value;
539 563
540 level = device->brightness->levels[bqc_value + 2]; 564 level = device->brightness->levels[bqc_value +
565 ACPI_VIDEO_FIRST_LEVEL];
541 } else { 566 } else {
542 level = bqc_value; 567 level = bqc_value;
543 } 568 }
@@ -571,7 +596,8 @@ acpi_video_device_lcd_get_level_current(struct acpi_video_device *device,
571 596
572 *level = acpi_video_bqc_value_to_level(device, *level); 597 *level = acpi_video_bqc_value_to_level(device, *level);
573 598
574 for (i = 2; i < device->brightness->count; i++) 599 for (i = ACPI_VIDEO_FIRST_LEVEL;
600 i < device->brightness->count; i++)
575 if (device->brightness->levels[i] == *level) { 601 if (device->brightness->levels[i] == *level) {
576 device->brightness->curr = *level; 602 device->brightness->curr = *level;
577 return 0; 603 return 0;
@@ -714,9 +740,37 @@ static int acpi_video_bqc_quirk(struct acpi_video_device *device,
714 740
715 /* 741 /*
716 * Some systems always report current brightness level as maximum 742 * Some systems always report current brightness level as maximum
717 * through _BQC, we need to test another value for them. 743 * through _BQC, we need to test another value for them. However,
744 * there is a subtlety:
745 *
746 * If the _BCL package ordering is descending, the first level
747 * (br->levels[2]) is likely to be 0, and if the number of levels
748 * matches the number of steps, we might confuse a returned level to
749 * mean the index.
750 *
751 * For example:
752 *
753 * current_level = max_level = 100
754 * test_level = 0
755 * returned level = 100
756 *
757 * In this case 100 means the level, not the index, and _BCM failed.
758 * Still, if the _BCL package ordering is descending, the index of
759 * level 0 is also 100, so we assume _BQC is indexed, when it's not.
760 *
761 * This causes all _BQC calls to return bogus values causing weird
762 * behavior from the user's perspective. For example:
763 *
764 * xbacklight -set 10; xbacklight -set 20;
765 *
766 * would flash to 90% and then slowly down to the desired level (20).
767 *
768 * The solution is simple; test anything other than the first level
769 * (e.g. 1).
718 */ 770 */
719 test_level = current_level == max_level ? br->levels[3] : max_level; 771 test_level = current_level == max_level
772 ? br->levels[ACPI_VIDEO_FIRST_LEVEL + 1]
773 : max_level;
720 774
721 result = acpi_video_device_lcd_set_level(device, test_level); 775 result = acpi_video_device_lcd_set_level(device, test_level);
722 if (result) 776 if (result)
@@ -730,8 +784,8 @@ static int acpi_video_bqc_quirk(struct acpi_video_device *device,
730 /* buggy _BQC found, need to find out if it uses index */ 784 /* buggy _BQC found, need to find out if it uses index */
731 if (level < br->count) { 785 if (level < br->count) {
732 if (br->flags._BCL_reversed) 786 if (br->flags._BCL_reversed)
733 level = br->count - 3 - level; 787 level = br->count - ACPI_VIDEO_FIRST_LEVEL - 1 - level;
734 if (br->levels[level + 2] == test_level) 788 if (br->levels[level + ACPI_VIDEO_FIRST_LEVEL] == test_level)
735 br->flags._BQC_use_index = 1; 789 br->flags._BQC_use_index = 1;
736 } 790 }
737 791
@@ -761,7 +815,7 @@ int acpi_video_get_levels(struct acpi_device *device,
761 goto out; 815 goto out;
762 } 816 }
763 817
764 if (obj->package.count < 2) { 818 if (obj->package.count < ACPI_VIDEO_FIRST_LEVEL) {
765 result = -EINVAL; 819 result = -EINVAL;
766 goto out; 820 goto out;
767 } 821 }
@@ -773,8 +827,13 @@ int acpi_video_get_levels(struct acpi_device *device,
773 goto out; 827 goto out;
774 } 828 }
775 829
776 br->levels = kmalloc((obj->package.count + 2) * sizeof *(br->levels), 830 /*
777 GFP_KERNEL); 831 * Note that we have to reserve 2 extra items (ACPI_VIDEO_FIRST_LEVEL),
832 * in order to account for buggy BIOS which don't export the first two
833 * special levels (see below)
834 */
835 br->levels = kmalloc((obj->package.count + ACPI_VIDEO_FIRST_LEVEL) *
836 sizeof(*br->levels), GFP_KERNEL);
778 if (!br->levels) { 837 if (!br->levels) {
779 result = -ENOMEM; 838 result = -ENOMEM;
780 goto out_free; 839 goto out_free;
@@ -788,7 +847,8 @@ int acpi_video_get_levels(struct acpi_device *device,
788 } 847 }
789 value = (u32) o->integer.value; 848 value = (u32) o->integer.value;
790 /* Skip duplicate entries */ 849 /* Skip duplicate entries */
791 if (count > 2 && br->levels[count - 1] == value) 850 if (count > ACPI_VIDEO_FIRST_LEVEL
851 && br->levels[count - 1] == value)
792 continue; 852 continue;
793 853
794 br->levels[count] = value; 854 br->levels[count] = value;
@@ -804,27 +864,30 @@ int acpi_video_get_levels(struct acpi_device *device,
804 * In this case, the first two elements in _BCL packages 864 * In this case, the first two elements in _BCL packages
805 * are also supported brightness levels that OS should take care of. 865 * are also supported brightness levels that OS should take care of.
806 */ 866 */
807 for (i = 2; i < count; i++) { 867 for (i = ACPI_VIDEO_FIRST_LEVEL; i < count; i++) {
808 if (br->levels[i] == br->levels[0]) 868 if (br->levels[i] == br->levels[ACPI_VIDEO_AC_LEVEL])
809 level_ac_battery++; 869 level_ac_battery++;
810 if (br->levels[i] == br->levels[1]) 870 if (br->levels[i] == br->levels[ACPI_VIDEO_BATTERY_LEVEL])
811 level_ac_battery++; 871 level_ac_battery++;
812 } 872 }
813 873
814 if (level_ac_battery < 2) { 874 if (level_ac_battery < ACPI_VIDEO_FIRST_LEVEL) {
815 level_ac_battery = 2 - level_ac_battery; 875 level_ac_battery = ACPI_VIDEO_FIRST_LEVEL - level_ac_battery;
816 br->flags._BCL_no_ac_battery_levels = 1; 876 br->flags._BCL_no_ac_battery_levels = 1;
817 for (i = (count - 1 + level_ac_battery); i >= 2; i--) 877 for (i = (count - 1 + level_ac_battery);
878 i >= ACPI_VIDEO_FIRST_LEVEL; i--)
818 br->levels[i] = br->levels[i - level_ac_battery]; 879 br->levels[i] = br->levels[i - level_ac_battery];
819 count += level_ac_battery; 880 count += level_ac_battery;
820 } else if (level_ac_battery > 2) 881 } else if (level_ac_battery > ACPI_VIDEO_FIRST_LEVEL)
821 ACPI_ERROR((AE_INFO, "Too many duplicates in _BCL package")); 882 ACPI_ERROR((AE_INFO, "Too many duplicates in _BCL package"));
822 883
823 /* Check if the _BCL package is in a reversed order */ 884 /* Check if the _BCL package is in a reversed order */
824 if (max_level == br->levels[2]) { 885 if (max_level == br->levels[ACPI_VIDEO_FIRST_LEVEL]) {
825 br->flags._BCL_reversed = 1; 886 br->flags._BCL_reversed = 1;
826 sort(&br->levels[2], count - 2, sizeof(br->levels[2]), 887 sort(&br->levels[ACPI_VIDEO_FIRST_LEVEL],
827 acpi_video_cmp_level, NULL); 888 count - ACPI_VIDEO_FIRST_LEVEL,
889 sizeof(br->levels[ACPI_VIDEO_FIRST_LEVEL]),
890 acpi_video_cmp_level, NULL);
828 } else if (max_level != br->levels[count - 1]) 891 } else if (max_level != br->levels[count - 1])
829 ACPI_ERROR((AE_INFO, 892 ACPI_ERROR((AE_INFO,
830 "Found unordered _BCL package")); 893 "Found unordered _BCL package"));
@@ -894,7 +957,7 @@ acpi_video_init_brightness(struct acpi_video_device *device)
894 * level_old is invalid (no matter whether it's a level 957 * level_old is invalid (no matter whether it's a level
895 * or an index). Set the backlight to max_level in this case. 958 * or an index). Set the backlight to max_level in this case.
896 */ 959 */
897 for (i = 2; i < br->count; i++) 960 for (i = ACPI_VIDEO_FIRST_LEVEL; i < br->count; i++)
898 if (level == br->levels[i]) 961 if (level == br->levels[i])
899 break; 962 break;
900 if (i == br->count || !level) 963 if (i == br->count || !level)
@@ -906,7 +969,8 @@ set_level:
906 goto out_free_levels; 969 goto out_free_levels;
907 970
908 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 971 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
909 "found %d brightness levels\n", br->count - 2)); 972 "found %d brightness levels\n",
973 br->count - ACPI_VIDEO_FIRST_LEVEL));
910 return 0; 974 return 0;
911 975
912out_free_levels: 976out_free_levels:
@@ -1297,7 +1361,7 @@ acpi_video_get_next_level(struct acpi_video_device *device,
1297 max = max_below = 0; 1361 max = max_below = 0;
1298 min = min_above = 255; 1362 min = min_above = 255;
1299 /* Find closest level to level_current */ 1363 /* Find closest level to level_current */
1300 for (i = 2; i < device->brightness->count; i++) { 1364 for (i = ACPI_VIDEO_FIRST_LEVEL; i < device->brightness->count; i++) {
1301 l = device->brightness->levels[i]; 1365 l = device->brightness->levels[i];
1302 if (abs(l - level_current) < abs(delta)) { 1366 if (abs(l - level_current) < abs(delta)) {
1303 delta = l - level_current; 1367 delta = l - level_current;
@@ -1307,7 +1371,7 @@ acpi_video_get_next_level(struct acpi_video_device *device,
1307 } 1371 }
1308 /* Ajust level_current to closest available level */ 1372 /* Ajust level_current to closest available level */
1309 level_current += delta; 1373 level_current += delta;
1310 for (i = 2; i < device->brightness->count; i++) { 1374 for (i = ACPI_VIDEO_FIRST_LEVEL; i < device->brightness->count; i++) {
1311 l = device->brightness->levels[i]; 1375 l = device->brightness->levels[i];
1312 if (l < min) 1376 if (l < min)
1313 min = l; 1377 min = l;
@@ -1680,7 +1744,8 @@ static void acpi_video_dev_register_backlight(struct acpi_video_device *device)
1680 1744
1681 memset(&props, 0, sizeof(struct backlight_properties)); 1745 memset(&props, 0, sizeof(struct backlight_properties));
1682 props.type = BACKLIGHT_FIRMWARE; 1746 props.type = BACKLIGHT_FIRMWARE;
1683 props.max_brightness = device->brightness->count - 3; 1747 props.max_brightness =
1748 device->brightness->count - ACPI_VIDEO_FIRST_LEVEL - 1;
1684 device->backlight = backlight_device_register(name, 1749 device->backlight = backlight_device_register(name,
1685 parent, 1750 parent,
1686 device, 1751 device,
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 4ef1e4624b2b..d42eeef9d928 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -67,6 +67,7 @@ MODULE_DESCRIPTION("ACPI Battery Driver");
67MODULE_LICENSE("GPL"); 67MODULE_LICENSE("GPL");
68 68
69static async_cookie_t async_cookie; 69static async_cookie_t async_cookie;
70static bool battery_driver_registered;
70static int battery_bix_broken_package; 71static int battery_bix_broken_package;
71static int battery_notification_delay_ms; 72static int battery_notification_delay_ms;
72static unsigned int cache_time = 1000; 73static unsigned int cache_time = 1000;
@@ -93,6 +94,11 @@ static const struct acpi_device_id battery_device_ids[] = {
93 94
94MODULE_DEVICE_TABLE(acpi, battery_device_ids); 95MODULE_DEVICE_TABLE(acpi, battery_device_ids);
95 96
97/* Lists of PMIC ACPI HIDs with an (often better) native battery driver */
98static const char * const acpi_battery_blacklist[] = {
99 "INT33F4", /* X-Powers AXP288 PMIC */
100};
101
96enum { 102enum {
97 ACPI_BATTERY_ALARM_PRESENT, 103 ACPI_BATTERY_ALARM_PRESENT,
98 ACPI_BATTERY_XINFO_PRESENT, 104 ACPI_BATTERY_XINFO_PRESENT,
@@ -1315,8 +1321,17 @@ static struct acpi_driver acpi_battery_driver = {
1315 1321
1316static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie) 1322static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie)
1317{ 1323{
1324 unsigned int i;
1318 int result; 1325 int result;
1319 1326
1327 for (i = 0; i < ARRAY_SIZE(acpi_battery_blacklist); i++)
1328 if (acpi_dev_present(acpi_battery_blacklist[i], "1", -1)) {
1329 pr_info(PREFIX ACPI_BATTERY_DEVICE_NAME
1330 ": found native %s PMIC, not loading\n",
1331 acpi_battery_blacklist[i]);
1332 return;
1333 }
1334
1320 dmi_check_system(bat_dmi_table); 1335 dmi_check_system(bat_dmi_table);
1321 1336
1322#ifdef CONFIG_ACPI_PROCFS_POWER 1337#ifdef CONFIG_ACPI_PROCFS_POWER
@@ -1329,6 +1344,7 @@ static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie)
1329 if (result < 0) 1344 if (result < 0)
1330 acpi_unlock_battery_dir(acpi_battery_dir); 1345 acpi_unlock_battery_dir(acpi_battery_dir);
1331#endif 1346#endif
1347 battery_driver_registered = (result == 0);
1332} 1348}
1333 1349
1334static int __init acpi_battery_init(void) 1350static int __init acpi_battery_init(void)
@@ -1343,9 +1359,11 @@ static int __init acpi_battery_init(void)
1343static void __exit acpi_battery_exit(void) 1359static void __exit acpi_battery_exit(void)
1344{ 1360{
1345 async_synchronize_cookie(async_cookie + 1); 1361 async_synchronize_cookie(async_cookie + 1);
1346 acpi_bus_unregister_driver(&acpi_battery_driver); 1362 if (battery_driver_registered)
1363 acpi_bus_unregister_driver(&acpi_battery_driver);
1347#ifdef CONFIG_ACPI_PROCFS_POWER 1364#ifdef CONFIG_ACPI_PROCFS_POWER
1348 acpi_unlock_battery_dir(acpi_battery_dir); 1365 if (acpi_battery_dir)
1366 acpi_unlock_battery_dir(acpi_battery_dir);
1349#endif 1367#endif
1350} 1368}
1351 1369
diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
index 4421f7c9981c..bb542acc0574 100644
--- a/drivers/acpi/blacklist.c
+++ b/drivers/acpi/blacklist.c
@@ -188,6 +188,14 @@ static struct dmi_system_id acpi_rev_dmi_table[] __initdata = {
188 DMI_MATCH(DMI_PRODUCT_NAME, "Latitude 3350"), 188 DMI_MATCH(DMI_PRODUCT_NAME, "Latitude 3350"),
189 }, 189 },
190 }, 190 },
191 {
192 .callback = dmi_enable_rev_override,
193 .ident = "DELL Inspiron 7537",
194 .matches = {
195 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
196 DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 7537"),
197 },
198 },
191#endif 199#endif
192 {} 200 {}
193}; 201};
diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index 3ca0729f7e0e..6cbe6036da99 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -132,49 +132,54 @@ __ATTR(_name, 0444, show_##_name, NULL)
132 132
133#define to_cpc_desc(a) container_of(a, struct cpc_desc, kobj) 133#define to_cpc_desc(a) container_of(a, struct cpc_desc, kobj)
134 134
135#define show_cppc_data(access_fn, struct_name, member_name) \
136 static ssize_t show_##member_name(struct kobject *kobj, \
137 struct attribute *attr, char *buf) \
138 { \
139 struct cpc_desc *cpc_ptr = to_cpc_desc(kobj); \
140 struct struct_name st_name = {0}; \
141 int ret; \
142 \
143 ret = access_fn(cpc_ptr->cpu_id, &st_name); \
144 if (ret) \
145 return ret; \
146 \
147 return scnprintf(buf, PAGE_SIZE, "%llu\n", \
148 (u64)st_name.member_name); \
149 } \
150 define_one_cppc_ro(member_name)
151
152show_cppc_data(cppc_get_perf_caps, cppc_perf_caps, highest_perf);
153show_cppc_data(cppc_get_perf_caps, cppc_perf_caps, lowest_perf);
154show_cppc_data(cppc_get_perf_caps, cppc_perf_caps, nominal_perf);
155show_cppc_data(cppc_get_perf_caps, cppc_perf_caps, lowest_nonlinear_perf);
156show_cppc_data(cppc_get_perf_ctrs, cppc_perf_fb_ctrs, reference_perf);
157show_cppc_data(cppc_get_perf_ctrs, cppc_perf_fb_ctrs, wraparound_time);
158
135static ssize_t show_feedback_ctrs(struct kobject *kobj, 159static ssize_t show_feedback_ctrs(struct kobject *kobj,
136 struct attribute *attr, char *buf) 160 struct attribute *attr, char *buf)
137{ 161{
138 struct cpc_desc *cpc_ptr = to_cpc_desc(kobj); 162 struct cpc_desc *cpc_ptr = to_cpc_desc(kobj);
139 struct cppc_perf_fb_ctrs fb_ctrs = {0}; 163 struct cppc_perf_fb_ctrs fb_ctrs = {0};
164 int ret;
140 165
141 cppc_get_perf_ctrs(cpc_ptr->cpu_id, &fb_ctrs); 166 ret = cppc_get_perf_ctrs(cpc_ptr->cpu_id, &fb_ctrs);
167 if (ret)
168 return ret;
142 169
143 return scnprintf(buf, PAGE_SIZE, "ref:%llu del:%llu\n", 170 return scnprintf(buf, PAGE_SIZE, "ref:%llu del:%llu\n",
144 fb_ctrs.reference, fb_ctrs.delivered); 171 fb_ctrs.reference, fb_ctrs.delivered);
145} 172}
146define_one_cppc_ro(feedback_ctrs); 173define_one_cppc_ro(feedback_ctrs);
147 174
148static ssize_t show_reference_perf(struct kobject *kobj,
149 struct attribute *attr, char *buf)
150{
151 struct cpc_desc *cpc_ptr = to_cpc_desc(kobj);
152 struct cppc_perf_fb_ctrs fb_ctrs = {0};
153
154 cppc_get_perf_ctrs(cpc_ptr->cpu_id, &fb_ctrs);
155
156 return scnprintf(buf, PAGE_SIZE, "%llu\n",
157 fb_ctrs.reference_perf);
158}
159define_one_cppc_ro(reference_perf);
160
161static ssize_t show_wraparound_time(struct kobject *kobj,
162 struct attribute *attr, char *buf)
163{
164 struct cpc_desc *cpc_ptr = to_cpc_desc(kobj);
165 struct cppc_perf_fb_ctrs fb_ctrs = {0};
166
167 cppc_get_perf_ctrs(cpc_ptr->cpu_id, &fb_ctrs);
168
169 return scnprintf(buf, PAGE_SIZE, "%llu\n", fb_ctrs.ctr_wrap_time);
170
171}
172define_one_cppc_ro(wraparound_time);
173
174static struct attribute *cppc_attrs[] = { 175static struct attribute *cppc_attrs[] = {
175 &feedback_ctrs.attr, 176 &feedback_ctrs.attr,
176 &reference_perf.attr, 177 &reference_perf.attr,
177 &wraparound_time.attr, 178 &wraparound_time.attr,
179 &highest_perf.attr,
180 &lowest_perf.attr,
181 &lowest_nonlinear_perf.attr,
182 &nominal_perf.attr,
178 NULL 183 NULL
179}; 184};
180 185
@@ -972,9 +977,9 @@ static int cpc_write(int cpu, struct cpc_register_resource *reg_res, u64 val)
972int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps) 977int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps)
973{ 978{
974 struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpunum); 979 struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpunum);
975 struct cpc_register_resource *highest_reg, *lowest_reg, *ref_perf, 980 struct cpc_register_resource *highest_reg, *lowest_reg,
976 *nom_perf; 981 *lowest_non_linear_reg, *nominal_reg;
977 u64 high, low, nom; 982 u64 high, low, nom, min_nonlinear;
978 int ret = 0, regs_in_pcc = 0; 983 int ret = 0, regs_in_pcc = 0;
979 984
980 if (!cpc_desc) { 985 if (!cpc_desc) {
@@ -984,12 +989,12 @@ int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps)
984 989
985 highest_reg = &cpc_desc->cpc_regs[HIGHEST_PERF]; 990 highest_reg = &cpc_desc->cpc_regs[HIGHEST_PERF];
986 lowest_reg = &cpc_desc->cpc_regs[LOWEST_PERF]; 991 lowest_reg = &cpc_desc->cpc_regs[LOWEST_PERF];
987 ref_perf = &cpc_desc->cpc_regs[REFERENCE_PERF]; 992 lowest_non_linear_reg = &cpc_desc->cpc_regs[LOW_NON_LINEAR_PERF];
988 nom_perf = &cpc_desc->cpc_regs[NOMINAL_PERF]; 993 nominal_reg = &cpc_desc->cpc_regs[NOMINAL_PERF];
989 994
990 /* Are any of the regs PCC ?*/ 995 /* Are any of the regs PCC ?*/
991 if (CPC_IN_PCC(highest_reg) || CPC_IN_PCC(lowest_reg) || 996 if (CPC_IN_PCC(highest_reg) || CPC_IN_PCC(lowest_reg) ||
992 CPC_IN_PCC(ref_perf) || CPC_IN_PCC(nom_perf)) { 997 CPC_IN_PCC(lowest_non_linear_reg) || CPC_IN_PCC(nominal_reg)) {
993 regs_in_pcc = 1; 998 regs_in_pcc = 1;
994 down_write(&pcc_data.pcc_lock); 999 down_write(&pcc_data.pcc_lock);
995 /* Ring doorbell once to update PCC subspace */ 1000 /* Ring doorbell once to update PCC subspace */
@@ -1005,10 +1010,13 @@ int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps)
1005 cpc_read(cpunum, lowest_reg, &low); 1010 cpc_read(cpunum, lowest_reg, &low);
1006 perf_caps->lowest_perf = low; 1011 perf_caps->lowest_perf = low;
1007 1012
1008 cpc_read(cpunum, nom_perf, &nom); 1013 cpc_read(cpunum, nominal_reg, &nom);
1009 perf_caps->nominal_perf = nom; 1014 perf_caps->nominal_perf = nom;
1010 1015
1011 if (!high || !low || !nom) 1016 cpc_read(cpunum, lowest_non_linear_reg, &min_nonlinear);
1017 perf_caps->lowest_nonlinear_perf = min_nonlinear;
1018
1019 if (!high || !low || !nom || !min_nonlinear)
1012 ret = -EFAULT; 1020 ret = -EFAULT;
1013 1021
1014out_err: 1022out_err:
@@ -1083,7 +1091,7 @@ int cppc_get_perf_ctrs(int cpunum, struct cppc_perf_fb_ctrs *perf_fb_ctrs)
1083 perf_fb_ctrs->delivered = delivered; 1091 perf_fb_ctrs->delivered = delivered;
1084 perf_fb_ctrs->reference = reference; 1092 perf_fb_ctrs->reference = reference;
1085 perf_fb_ctrs->reference_perf = ref_perf; 1093 perf_fb_ctrs->reference_perf = ref_perf;
1086 perf_fb_ctrs->ctr_wrap_time = ctr_wrap_time; 1094 perf_fb_ctrs->wraparound_time = ctr_wrap_time;
1087out_err: 1095out_err:
1088 if (regs_in_pcc) 1096 if (regs_in_pcc)
1089 up_write(&pcc_data.pcc_lock); 1097 up_write(&pcc_data.pcc_lock);
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index f15900132912..66229ffa909b 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -65,8 +65,6 @@ static inline void acpi_cmos_rtc_init(void) {}
65#endif 65#endif
66int acpi_rev_override_setup(char *str); 66int acpi_rev_override_setup(char *str);
67 67
68extern bool acpi_force_hot_remove;
69
70void acpi_sysfs_add_hotplug_profile(struct acpi_hotplug_profile *hotplug, 68void acpi_sysfs_add_hotplug_profile(struct acpi_hotplug_profile *hotplug,
71 const char *name); 69 const char *name);
72int acpi_scan_add_handler_with_hotplug(struct acpi_scan_handler *handler, 70int acpi_scan_add_handler_with_hotplug(struct acpi_scan_handler *handler,
diff --git a/drivers/acpi/pmic/intel_pmic_chtwc.c b/drivers/acpi/pmic/intel_pmic_chtwc.c
new file mode 100644
index 000000000000..85636d7a9d39
--- /dev/null
+++ b/drivers/acpi/pmic/intel_pmic_chtwc.c
@@ -0,0 +1,280 @@
1/*
2 * Intel CHT Whiskey Cove PMIC operation region driver
3 * Copyright (C) 2017 Hans de Goede <hdegoede@redhat.com>
4 *
5 * Based on various non upstream patches to support the CHT Whiskey Cove PMIC:
6 * Copyright (C) 2013-2015 Intel Corporation. All rights reserved.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */
17
18#include <linux/acpi.h>
19#include <linux/init.h>
20#include <linux/mfd/intel_soc_pmic.h>
21#include <linux/platform_device.h>
22#include <linux/regmap.h>
23#include "intel_pmic.h"
24
25#define CHT_WC_V1P05A_CTRL 0x6e3b
26#define CHT_WC_V1P15_CTRL 0x6e3c
27#define CHT_WC_V1P05A_VSEL 0x6e3d
28#define CHT_WC_V1P15_VSEL 0x6e3e
29#define CHT_WC_V1P8A_CTRL 0x6e56
30#define CHT_WC_V1P8SX_CTRL 0x6e57
31#define CHT_WC_VDDQ_CTRL 0x6e58
32#define CHT_WC_V1P2A_CTRL 0x6e59
33#define CHT_WC_V1P2SX_CTRL 0x6e5a
34#define CHT_WC_V1P8A_VSEL 0x6e5b
35#define CHT_WC_VDDQ_VSEL 0x6e5c
36#define CHT_WC_V2P8SX_CTRL 0x6e5d
37#define CHT_WC_V3P3A_CTRL 0x6e5e
38#define CHT_WC_V3P3SD_CTRL 0x6e5f
39#define CHT_WC_VSDIO_CTRL 0x6e67
40#define CHT_WC_V3P3A_VSEL 0x6e68
41#define CHT_WC_VPROG1A_CTRL 0x6e90
42#define CHT_WC_VPROG1B_CTRL 0x6e91
43#define CHT_WC_VPROG1F_CTRL 0x6e95
44#define CHT_WC_VPROG2D_CTRL 0x6e99
45#define CHT_WC_VPROG3A_CTRL 0x6e9a
46#define CHT_WC_VPROG3B_CTRL 0x6e9b
47#define CHT_WC_VPROG4A_CTRL 0x6e9c
48#define CHT_WC_VPROG4B_CTRL 0x6e9d
49#define CHT_WC_VPROG4C_CTRL 0x6e9e
50#define CHT_WC_VPROG4D_CTRL 0x6e9f
51#define CHT_WC_VPROG5A_CTRL 0x6ea0
52#define CHT_WC_VPROG5B_CTRL 0x6ea1
53#define CHT_WC_VPROG6A_CTRL 0x6ea2
54#define CHT_WC_VPROG6B_CTRL 0x6ea3
55#define CHT_WC_VPROG1A_VSEL 0x6ec0
56#define CHT_WC_VPROG1B_VSEL 0x6ec1
57#define CHT_WC_V1P8SX_VSEL 0x6ec2
58#define CHT_WC_V1P2SX_VSEL 0x6ec3
59#define CHT_WC_V1P2A_VSEL 0x6ec4
60#define CHT_WC_VPROG1F_VSEL 0x6ec5
61#define CHT_WC_VSDIO_VSEL 0x6ec6
62#define CHT_WC_V2P8SX_VSEL 0x6ec7
63#define CHT_WC_V3P3SD_VSEL 0x6ec8
64#define CHT_WC_VPROG2D_VSEL 0x6ec9
65#define CHT_WC_VPROG3A_VSEL 0x6eca
66#define CHT_WC_VPROG3B_VSEL 0x6ecb
67#define CHT_WC_VPROG4A_VSEL 0x6ecc
68#define CHT_WC_VPROG4B_VSEL 0x6ecd
69#define CHT_WC_VPROG4C_VSEL 0x6ece
70#define CHT_WC_VPROG4D_VSEL 0x6ecf
71#define CHT_WC_VPROG5A_VSEL 0x6ed0
72#define CHT_WC_VPROG5B_VSEL 0x6ed1
73#define CHT_WC_VPROG6A_VSEL 0x6ed2
74#define CHT_WC_VPROG6B_VSEL 0x6ed3
75
76/*
77 * Regulator support is based on the non upstream patch:
78 * "regulator: whiskey_cove: implements Whiskey Cove pmic VRF support"
79 * https://github.com/intel-aero/meta-intel-aero/blob/master/recipes-kernel/linux/linux-yocto/0019-regulator-whiskey_cove-implements-WhiskeyCove-pmic-V.patch
80 */
81static struct pmic_table power_table[] = {
82 {
83 .address = 0x0,
84 .reg = CHT_WC_V1P8A_CTRL,
85 .bit = 0x01,
86 }, /* V18A */
87 {
88 .address = 0x04,
89 .reg = CHT_WC_V1P8SX_CTRL,
90 .bit = 0x07,
91 }, /* V18X */
92 {
93 .address = 0x08,
94 .reg = CHT_WC_VDDQ_CTRL,
95 .bit = 0x01,
96 }, /* VDDQ */
97 {
98 .address = 0x0c,
99 .reg = CHT_WC_V1P2A_CTRL,
100 .bit = 0x07,
101 }, /* V12A */
102 {
103 .address = 0x10,
104 .reg = CHT_WC_V1P2SX_CTRL,
105 .bit = 0x07,
106 }, /* V12X */
107 {
108 .address = 0x14,
109 .reg = CHT_WC_V2P8SX_CTRL,
110 .bit = 0x07,
111 }, /* V28X */
112 {
113 .address = 0x18,
114 .reg = CHT_WC_V3P3A_CTRL,
115 .bit = 0x01,
116 }, /* V33A */
117 {
118 .address = 0x1c,
119 .reg = CHT_WC_V3P3SD_CTRL,
120 .bit = 0x07,
121 }, /* V3SD */
122 {
123 .address = 0x20,
124 .reg = CHT_WC_VSDIO_CTRL,
125 .bit = 0x07,
126 }, /* VSD */
127/* {
128 .address = 0x24,
129 .reg = ??,
130 .bit = ??,
131 }, ** VSW2 */
132/* {
133 .address = 0x28,
134 .reg = ??,
135 .bit = ??,
136 }, ** VSW1 */
137/* {
138 .address = 0x2c,
139 .reg = ??,
140 .bit = ??,
141 }, ** VUPY */
142/* {
143 .address = 0x30,
144 .reg = ??,
145 .bit = ??,
146 }, ** VRSO */
147 {
148 .address = 0x34,
149 .reg = CHT_WC_VPROG1A_CTRL,
150 .bit = 0x07,
151 }, /* VP1A */
152 {
153 .address = 0x38,
154 .reg = CHT_WC_VPROG1B_CTRL,
155 .bit = 0x07,
156 }, /* VP1B */
157 {
158 .address = 0x3c,
159 .reg = CHT_WC_VPROG1F_CTRL,
160 .bit = 0x07,
161 }, /* VP1F */
162 {
163 .address = 0x40,
164 .reg = CHT_WC_VPROG2D_CTRL,
165 .bit = 0x07,
166 }, /* VP2D */
167 {
168 .address = 0x44,
169 .reg = CHT_WC_VPROG3A_CTRL,
170 .bit = 0x07,
171 }, /* VP3A */
172 {
173 .address = 0x48,
174 .reg = CHT_WC_VPROG3B_CTRL,
175 .bit = 0x07,
176 }, /* VP3B */
177 {
178 .address = 0x4c,
179 .reg = CHT_WC_VPROG4A_CTRL,
180 .bit = 0x07,
181 }, /* VP4A */
182 {
183 .address = 0x50,
184 .reg = CHT_WC_VPROG4B_CTRL,
185 .bit = 0x07,
186 }, /* VP4B */
187 {
188 .address = 0x54,
189 .reg = CHT_WC_VPROG4C_CTRL,
190 .bit = 0x07,
191 }, /* VP4C */
192 {
193 .address = 0x58,
194 .reg = CHT_WC_VPROG4D_CTRL,
195 .bit = 0x07,
196 }, /* VP4D */
197 {
198 .address = 0x5c,
199 .reg = CHT_WC_VPROG5A_CTRL,
200 .bit = 0x07,
201 }, /* VP5A */
202 {
203 .address = 0x60,
204 .reg = CHT_WC_VPROG5B_CTRL,
205 .bit = 0x07,
206 }, /* VP5B */
207 {
208 .address = 0x64,
209 .reg = CHT_WC_VPROG6A_CTRL,
210 .bit = 0x07,
211 }, /* VP6A */
212 {
213 .address = 0x68,
214 .reg = CHT_WC_VPROG6B_CTRL,
215 .bit = 0x07,
216 }, /* VP6B */
217/* {
218 .address = 0x6c,
219 .reg = ??,
220 .bit = ??,
221 } ** VP7A */
222};
223
224static int intel_cht_wc_pmic_get_power(struct regmap *regmap, int reg,
225 int bit, u64 *value)
226{
227 int data;
228
229 if (regmap_read(regmap, reg, &data))
230 return -EIO;
231
232 *value = (data & bit) ? 1 : 0;
233 return 0;
234}
235
236static int intel_cht_wc_pmic_update_power(struct regmap *regmap, int reg,
237 int bitmask, bool on)
238{
239 return regmap_update_bits(regmap, reg, bitmask, on ? 1 : 0);
240}
241
242/*
243 * The thermal table and ops are empty, we do not support the Thermal opregion
244 * (DPTF) due to lacking documentation.
245 */
246static struct intel_pmic_opregion_data intel_cht_wc_pmic_opregion_data = {
247 .get_power = intel_cht_wc_pmic_get_power,
248 .update_power = intel_cht_wc_pmic_update_power,
249 .power_table = power_table,
250 .power_table_count = ARRAY_SIZE(power_table),
251};
252
253static int intel_cht_wc_pmic_opregion_probe(struct platform_device *pdev)
254{
255 struct intel_soc_pmic *pmic = dev_get_drvdata(pdev->dev.parent);
256
257 return intel_pmic_install_opregion_handler(&pdev->dev,
258 ACPI_HANDLE(pdev->dev.parent),
259 pmic->regmap,
260 &intel_cht_wc_pmic_opregion_data);
261}
262
263static struct platform_device_id cht_wc_opregion_id_table[] = {
264 { .name = "cht_wcove_region" },
265 {},
266};
267MODULE_DEVICE_TABLE(platform, cht_wc_opregion_id_table);
268
269static struct platform_driver intel_cht_wc_pmic_opregion_driver = {
270 .probe = intel_cht_wc_pmic_opregion_probe,
271 .driver = {
272 .name = "cht_whiskey_cove_pmic",
273 },
274 .id_table = cht_wc_opregion_id_table,
275};
276module_platform_driver(intel_cht_wc_pmic_opregion_driver);
277
278MODULE_DESCRIPTION("Intel CHT Whiskey Cove PMIC operation region driver");
279MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>");
280MODULE_LICENSE("GPL");
diff --git a/drivers/acpi/pmic/intel_pmic_xpower.c b/drivers/acpi/pmic/intel_pmic_xpower.c
index e6e991ac20f3..55f51115f016 100644
--- a/drivers/acpi/pmic/intel_pmic_xpower.c
+++ b/drivers/acpi/pmic/intel_pmic_xpower.c
@@ -18,7 +18,6 @@
18#include <linux/mfd/axp20x.h> 18#include <linux/mfd/axp20x.h>
19#include <linux/regmap.h> 19#include <linux/regmap.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/iio/consumer.h>
22#include "intel_pmic.h" 21#include "intel_pmic.h"
23 22
24#define XPOWER_GPADC_LOW 0x5b 23#define XPOWER_GPADC_LOW 0x5b
@@ -186,28 +185,16 @@ static int intel_xpower_pmic_update_power(struct regmap *regmap, int reg,
186 * @regmap: regmap of the PMIC device 185 * @regmap: regmap of the PMIC device
187 * @reg: register to get the reading 186 * @reg: register to get the reading
188 * 187 *
189 * We could get the sensor value by manipulating the HW regs here, but since
190 * the axp288 IIO driver may also access the same regs at the same time, the
191 * APIs provided by IIO subsystem are used here instead to avoid problems. As
192 * a result, the two passed in params are of no actual use.
193 *
194 * Return a positive value on success, errno on failure. 188 * Return a positive value on success, errno on failure.
195 */ 189 */
196static int intel_xpower_pmic_get_raw_temp(struct regmap *regmap, int reg) 190static int intel_xpower_pmic_get_raw_temp(struct regmap *regmap, int reg)
197{ 191{
198 struct iio_channel *gpadc_chan; 192 u8 buf[2];
199 int ret, val;
200
201 gpadc_chan = iio_channel_get(NULL, "axp288-system-temp");
202 if (IS_ERR_OR_NULL(gpadc_chan))
203 return -EACCES;
204 193
205 ret = iio_read_channel_raw(gpadc_chan, &val); 194 if (regmap_bulk_read(regmap, AXP288_GP_ADC_H, buf, 2))
206 if (ret < 0) 195 return -EIO;
207 val = ret;
208 196
209 iio_channel_release(gpadc_chan); 197 return (buf[0] << 4) + ((buf[1] >> 4) & 0x0F);
210 return val;
211} 198}
212 199
213static struct intel_pmic_opregion_data intel_xpower_pmic_opregion_data = { 200static struct intel_pmic_opregion_data intel_xpower_pmic_opregion_data = {
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 2433569b02ef..c26931067415 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -30,12 +30,6 @@ extern struct acpi_device *acpi_root;
30 30
31#define INVALID_ACPI_HANDLE ((acpi_handle)empty_zero_page) 31#define INVALID_ACPI_HANDLE ((acpi_handle)empty_zero_page)
32 32
33/*
34 * If set, devices will be hot-removed even if they cannot be put offline
35 * gracefully (from the kernel's standpoint).
36 */
37bool acpi_force_hot_remove;
38
39static const char *dummy_hid = "device"; 33static const char *dummy_hid = "device";
40 34
41static LIST_HEAD(acpi_dep_list); 35static LIST_HEAD(acpi_dep_list);
@@ -170,9 +164,6 @@ static acpi_status acpi_bus_offline(acpi_handle handle, u32 lvl, void *data,
170 pn->put_online = false; 164 pn->put_online = false;
171 } 165 }
172 ret = device_offline(pn->dev); 166 ret = device_offline(pn->dev);
173 if (acpi_force_hot_remove)
174 continue;
175
176 if (ret >= 0) { 167 if (ret >= 0) {
177 pn->put_online = !ret; 168 pn->put_online = !ret;
178 } else { 169 } else {
@@ -241,11 +232,11 @@ static int acpi_scan_try_to_offline(struct acpi_device *device)
241 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, 232 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
242 NULL, acpi_bus_offline, (void *)true, 233 NULL, acpi_bus_offline, (void *)true,
243 (void **)&errdev); 234 (void **)&errdev);
244 if (!errdev || acpi_force_hot_remove) 235 if (!errdev)
245 acpi_bus_offline(handle, 0, (void *)true, 236 acpi_bus_offline(handle, 0, (void *)true,
246 (void **)&errdev); 237 (void **)&errdev);
247 238
248 if (errdev && !acpi_force_hot_remove) { 239 if (errdev) {
249 dev_warn(errdev, "Offline failed.\n"); 240 dev_warn(errdev, "Offline failed.\n");
250 acpi_bus_online(handle, 0, NULL, NULL); 241 acpi_bus_online(handle, 0, NULL, NULL);
251 acpi_walk_namespace(ACPI_TYPE_ANY, handle, 242 acpi_walk_namespace(ACPI_TYPE_ANY, handle,
@@ -263,8 +254,7 @@ static int acpi_scan_hot_remove(struct acpi_device *device)
263 unsigned long long sta; 254 unsigned long long sta;
264 acpi_status status; 255 acpi_status status;
265 256
266 if (device->handler && device->handler->hotplug.demand_offline 257 if (device->handler && device->handler->hotplug.demand_offline) {
267 && !acpi_force_hot_remove) {
268 if (!acpi_scan_is_offline(device, true)) 258 if (!acpi_scan_is_offline(device, true))
269 return -EBUSY; 259 return -EBUSY;
270 } else { 260 } else {
@@ -1850,6 +1840,8 @@ static void acpi_bus_attach(struct acpi_device *device)
1850 device->flags.power_manageable = 0; 1840 device->flags.power_manageable = 0;
1851 1841
1852 device->flags.initialized = true; 1842 device->flags.initialized = true;
1843 } else if (device->flags.visited) {
1844 goto ok;
1853 } 1845 }
1854 1846
1855 ret = acpi_scan_attach_handler(device); 1847 ret = acpi_scan_attach_handler(device);
@@ -1866,10 +1858,10 @@ static void acpi_bus_attach(struct acpi_device *device)
1866 if (ret < 0) 1858 if (ret < 0)
1867 return; 1859 return;
1868 1860
1869 if (ret > 0 || !device->pnp.type.platform_id) 1861 if (device->pnp.type.platform_id)
1870 acpi_device_set_enumerated(device);
1871 else
1872 acpi_default_enumeration(device); 1862 acpi_default_enumeration(device);
1863 else
1864 acpi_device_set_enumerated(device);
1873 1865
1874 ok: 1866 ok:
1875 list_for_each_entry(child, &device->children, node) 1867 list_for_each_entry(child, &device->children, node)
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
index cf05ae973381..1b5ee1e0e5a3 100644
--- a/drivers/acpi/sysfs.c
+++ b/drivers/acpi/sysfs.c
@@ -921,7 +921,7 @@ void acpi_sysfs_add_hotplug_profile(struct acpi_hotplug_profile *hotplug,
921static ssize_t force_remove_show(struct kobject *kobj, 921static ssize_t force_remove_show(struct kobject *kobj,
922 struct kobj_attribute *attr, char *buf) 922 struct kobj_attribute *attr, char *buf)
923{ 923{
924 return sprintf(buf, "%d\n", !!acpi_force_hot_remove); 924 return sprintf(buf, "%d\n", 0);
925} 925}
926 926
927static ssize_t force_remove_store(struct kobject *kobj, 927static ssize_t force_remove_store(struct kobject *kobj,
@@ -935,9 +935,10 @@ static ssize_t force_remove_store(struct kobject *kobj,
935 if (ret < 0) 935 if (ret < 0)
936 return ret; 936 return ret;
937 937
938 lock_device_hotplug(); 938 if (val) {
939 acpi_force_hot_remove = val; 939 pr_err("Enabling force_remove is not supported anymore. Please report to linux-acpi@vger.kernel.org if you depend on this functionality\n");
940 unlock_device_hotplug(); 940 return -EINVAL;
941 }
941 return size; 942 return size;
942} 943}
943 944
diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
index 2604189d6cd1..0dae722ab2ec 100644
--- a/drivers/acpi/tables.c
+++ b/drivers/acpi/tables.c
@@ -311,22 +311,6 @@ acpi_parse_entries_array(char *id, unsigned long table_size,
311} 311}
312 312
313int __init 313int __init
314acpi_parse_entries(char *id,
315 unsigned long table_size,
316 acpi_tbl_entry_handler handler,
317 struct acpi_table_header *table_header,
318 int entry_id, unsigned int max_entries)
319{
320 struct acpi_subtable_proc proc = {
321 .id = entry_id,
322 .handler = handler,
323 };
324
325 return acpi_parse_entries_array(id, table_size, table_header,
326 &proc, 1, max_entries);
327}
328
329int __init
330acpi_table_parse_entries_array(char *id, 314acpi_table_parse_entries_array(char *id,
331 unsigned long table_size, 315 unsigned long table_size,
332 struct acpi_subtable_proc *proc, int proc_num, 316 struct acpi_subtable_proc *proc, int proc_num,
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 22c09952e177..27d0dcfcf47d 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -736,6 +736,72 @@ bool acpi_dev_found(const char *hid)
736} 736}
737EXPORT_SYMBOL(acpi_dev_found); 737EXPORT_SYMBOL(acpi_dev_found);
738 738
739struct acpi_dev_present_info {
740 struct acpi_device_id hid[2];
741 const char *uid;
742 s64 hrv;
743};
744
745static int acpi_dev_present_cb(struct device *dev, void *data)
746{
747 struct acpi_device *adev = to_acpi_device(dev);
748 struct acpi_dev_present_info *match = data;
749 unsigned long long hrv;
750 acpi_status status;
751
752 if (acpi_match_device_ids(adev, match->hid))
753 return 0;
754
755 if (match->uid && (!adev->pnp.unique_id ||
756 strcmp(adev->pnp.unique_id, match->uid)))
757 return 0;
758
759 if (match->hrv == -1)
760 return 1;
761
762 status = acpi_evaluate_integer(adev->handle, "_HRV", NULL, &hrv);
763 if (ACPI_FAILURE(status))
764 return 0;
765
766 return hrv == match->hrv;
767}
768
769/**
770 * acpi_dev_present - Detect that a given ACPI device is present
771 * @hid: Hardware ID of the device.
772 * @uid: Unique ID of the device, pass NULL to not check _UID
773 * @hrv: Hardware Revision of the device, pass -1 to not check _HRV
774 *
775 * Return %true if a matching device was present at the moment of invocation.
776 * Note that if the device is pluggable, it may since have disappeared.
777 *
778 * Note that unlike acpi_dev_found() this function checks the status
779 * of the device. So for devices which are present in the dsdt, but
780 * which are disabled (their _STA callback returns 0) this function
781 * will return false.
782 *
783 * For this function to work, acpi_bus_scan() must have been executed
784 * which happens in the subsys_initcall() subsection. Hence, do not
785 * call from a subsys_initcall() or earlier (use acpi_get_devices()
786 * instead). Calling from module_init() is fine (which is synonymous
787 * with device_initcall()).
788 */
789bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
790{
791 struct acpi_dev_present_info match = {};
792 struct device *dev;
793
794 strlcpy(match.hid[0].id, hid, sizeof(match.hid[0].id));
795 match.uid = uid;
796 match.hrv = hrv;
797
798 dev = bus_find_device(&acpi_bus_type, NULL, &match,
799 acpi_dev_present_cb);
800
801 return !!dev;
802}
803EXPORT_SYMBOL(acpi_dev_present);
804
739/* 805/*
740 * acpi_backlight= handling, this is done here rather then in video_detect.c 806 * acpi_backlight= handling, this is done here rather then in video_detect.c
741 * because __setup cannot be used in modules. 807 * because __setup cannot be used in modules.
diff --git a/drivers/power/supply/axp288_charger.c b/drivers/power/supply/axp288_charger.c
index 6be2fe27bb07..d51ebd1da65e 100644
--- a/drivers/power/supply/axp288_charger.c
+++ b/drivers/power/supply/axp288_charger.c
@@ -14,6 +14,7 @@
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 */ 15 */
16 16
17#include <linux/acpi.h>
17#include <linux/module.h> 18#include <linux/module.h>
18#include <linux/device.h> 19#include <linux/device.h>
19#include <linux/regmap.h> 20#include <linux/regmap.h>
@@ -113,7 +114,8 @@
113#define ILIM_3000MA 3000 /* 3000mA */ 114#define ILIM_3000MA 3000 /* 3000mA */
114 115
115#define AXP288_EXTCON_DEV_NAME "axp288_extcon" 116#define AXP288_EXTCON_DEV_NAME "axp288_extcon"
116#define USB_HOST_EXTCON_DEV_NAME "INT3496:00" 117#define USB_HOST_EXTCON_HID "INT3496"
118#define USB_HOST_EXTCON_NAME "INT3496:00"
117 119
118static const unsigned int cable_ids[] = 120static const unsigned int cable_ids[] =
119 { EXTCON_CHG_USB_SDP, EXTCON_CHG_USB_CDP, EXTCON_CHG_USB_DCP }; 121 { EXTCON_CHG_USB_SDP, EXTCON_CHG_USB_CDP, EXTCON_CHG_USB_DCP };
@@ -807,10 +809,14 @@ static int axp288_charger_probe(struct platform_device *pdev)
807 return -EPROBE_DEFER; 809 return -EPROBE_DEFER;
808 } 810 }
809 811
810 info->otg.cable = extcon_get_extcon_dev(USB_HOST_EXTCON_DEV_NAME); 812 if (acpi_dev_present(USB_HOST_EXTCON_HID, NULL, -1)) {
811 if (info->otg.cable == NULL) { 813 info->otg.cable = extcon_get_extcon_dev(USB_HOST_EXTCON_NAME);
812 dev_dbg(dev, "EXTCON_USB_HOST is not ready, probe deferred\n"); 814 if (info->otg.cable == NULL) {
813 return -EPROBE_DEFER; 815 dev_dbg(dev, "EXTCON_USB_HOST is not ready, probe deferred\n");
816 return -EPROBE_DEFER;
817 }
818 dev_info(&pdev->dev,
819 "Using " USB_HOST_EXTCON_HID " extcon for usb-id\n");
814 } 820 }
815 821
816 platform_set_drvdata(pdev, info); 822 platform_set_drvdata(pdev, info);
@@ -849,13 +855,15 @@ static int axp288_charger_probe(struct platform_device *pdev)
849 /* Register for OTG notification */ 855 /* Register for OTG notification */
850 INIT_WORK(&info->otg.work, axp288_charger_otg_evt_worker); 856 INIT_WORK(&info->otg.work, axp288_charger_otg_evt_worker);
851 info->otg.id_nb.notifier_call = axp288_charger_handle_otg_evt; 857 info->otg.id_nb.notifier_call = axp288_charger_handle_otg_evt;
852 ret = devm_extcon_register_notifier(&pdev->dev, info->otg.cable, 858 if (info->otg.cable) {
859 ret = devm_extcon_register_notifier(&pdev->dev, info->otg.cable,
853 EXTCON_USB_HOST, &info->otg.id_nb); 860 EXTCON_USB_HOST, &info->otg.id_nb);
854 if (ret) { 861 if (ret) {
855 dev_err(dev, "failed to register EXTCON_USB_HOST notifier\n"); 862 dev_err(dev, "failed to register EXTCON_USB_HOST notifier\n");
856 return ret; 863 return ret;
864 }
865 schedule_work(&info->otg.work);
857 } 866 }
858 schedule_work(&info->otg.work);
859 867
860 /* Register charger interrupts */ 868 /* Register charger interrupts */
861 for (i = 0; i < CHRG_INTR_END; i++) { 869 for (i = 0; i < CHRG_INTR_END; i++) {
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index ef0ae8aaa567..b53c058e7009 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -88,6 +88,7 @@ acpi_evaluate_dsm_typed(acpi_handle handle, const u8 *uuid, u64 rev, u64 func,
88 } 88 }
89 89
90bool acpi_dev_found(const char *hid); 90bool acpi_dev_found(const char *hid);
91bool acpi_dev_present(const char *hid, const char *uid, s64 hrv);
91 92
92#ifdef CONFIG_ACPI 93#ifdef CONFIG_ACPI
93 94
diff --git a/include/acpi/cppc_acpi.h b/include/acpi/cppc_acpi.h
index 427a7c3e6c75..2010c0516f27 100644
--- a/include/acpi/cppc_acpi.h
+++ b/include/acpi/cppc_acpi.h
@@ -103,6 +103,7 @@ struct cppc_perf_caps {
103 u32 highest_perf; 103 u32 highest_perf;
104 u32 nominal_perf; 104 u32 nominal_perf;
105 u32 lowest_perf; 105 u32 lowest_perf;
106 u32 lowest_nonlinear_perf;
106}; 107};
107 108
108struct cppc_perf_ctrls { 109struct cppc_perf_ctrls {
@@ -115,7 +116,7 @@ struct cppc_perf_fb_ctrs {
115 u64 reference; 116 u64 reference;
116 u64 delivered; 117 u64 delivered;
117 u64 reference_perf; 118 u64 reference_perf;
118 u64 ctr_wrap_time; 119 u64 wraparound_time;
119}; 120};
120 121
121/* Per CPU container for runtime CPPC management. */ 122/* Per CPU container for runtime CPPC management. */
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 9b05886f9773..07f8924a2dfd 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -233,10 +233,6 @@ int acpi_numa_init (void);
233 233
234int acpi_table_init (void); 234int acpi_table_init (void);
235int acpi_table_parse(char *id, acpi_tbl_table_handler handler); 235int acpi_table_parse(char *id, acpi_tbl_table_handler handler);
236int __init acpi_parse_entries(char *id, unsigned long table_size,
237 acpi_tbl_entry_handler handler,
238 struct acpi_table_header *table_header,
239 int entry_id, unsigned int max_entries);
240int __init acpi_table_parse_entries(char *id, unsigned long table_size, 236int __init acpi_table_parse_entries(char *id, unsigned long table_size,
241 int entry_id, 237 int entry_id,
242 acpi_tbl_entry_handler handler, 238 acpi_tbl_entry_handler handler,
@@ -611,6 +607,11 @@ static inline bool acpi_dev_found(const char *hid)
611 return false; 607 return false;
612} 608}
613 609
610static inline bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
611{
612 return false;
613}
614
614static inline bool is_acpi_node(struct fwnode_handle *fwnode) 615static inline bool is_acpi_node(struct fwnode_handle *fwnode)
615{ 616{
616 return false; 617 return false;