Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+617 -176
+8
Documentation/ABI/obsolete/sysfs-firmware-acpi
··· 1 + What: /sys/firmware/acpi/hotplug/force_remove 2 + Date: Mar 2017 3 + Contact: Rafael J. Wysocki <rafael.j.wysocki@intel.com> 4 + Description: 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.
-10
Documentation/ABI/testing/sysfs-firmware-acpi
··· 44 44 or 0 (unset). Attempts to write any other values to it will 45 45 cause -EINVAL to be returned. 46 46 47 - What: /sys/firmware/acpi/hotplug/force_remove 48 - Date: May 2013 49 - Contact: Rafael J. Wysocki <rafael.j.wysocki@intel.com> 50 - Description: 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 - 57 47 What: /sys/firmware/acpi/interrupts/ 58 48 Date: February 2008 59 49 Contact: Len Brown <lenb@kernel.org>
+5 -5
Documentation/acpi/linuxized-acpica.txt
··· 24 24 The homepage of ACPICA project is: www.acpica.org, it is maintained and 25 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 28 adaptation is included: 29 29 30 30 +---------------------------------------------------------+ ··· 110 110 Linux patches. The patches generated by this process are referred to as 111 111 "linuxized ACPICA patches". The release process is carried out on a local 112 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 114 ACPICA release patchset for the Linux ACPI community. This process is 115 115 illustrated in the following figure: 116 116 ··· 165 165 <http://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git>. 166 166 167 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 169 porting issues. Currently this build process only takes care of the 170 170 following kernel configuration options: 171 171 CONFIG_ACPI/CONFIG_ACPI_DEBUG/CONFIG_ACPI_DEBUGGER ··· 195 195 release utilities (please refer to Section 4 below for the details). 196 196 3. Linux specific features - Sometimes it's impossible to use the 197 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 199 Those changes may not be acceptable by ACPICA upstream and in such cases 200 200 they are left as committed ACPICA divergences unless the ACPICA side can 201 201 implement new mechanisms as replacements for them. 202 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 204 break the Linux kernel, leaving us build/boot failures. In order to 205 205 avoid breaking Linux bisection, fixes are applied directly to the 206 206 linuxized ACPICA patches during the release process. When the release
+7 -1
drivers/acpi/Kconfig
··· 505 505 506 506 config XPOWER_PMIC_OPREGION 507 507 bool "ACPI operation region support for XPower AXP288 PMIC" 508 - depends on AXP288_ADC = y 508 + depends on MFD_AXP20X_I2C 509 509 help 510 510 This config adds ACPI operation region support for XPower AXP288 PMIC. 511 511 ··· 514 514 depends on INTEL_SOC_PMIC 515 515 help 516 516 This config adds ACPI operation region support for BXT WhiskeyCove PMIC. 517 + 518 + config 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. 517 523 518 524 endif 519 525
+1
drivers/acpi/Makefile
··· 101 101 obj-$(CONFIG_CRC_PMIC_OPREGION) += pmic/intel_pmic_crc.o 102 102 obj-$(CONFIG_XPOWER_PMIC_OPREGION) += pmic/intel_pmic_xpower.o 103 103 obj-$(CONFIG_BXT_WC_PMIC_OPREGION) += pmic/intel_pmic_bxtwc.o 104 + obj-$(CONFIG_CHT_WC_PMIC_OPREGION) += pmic/intel_pmic_chtwc.o 104 105 105 106 obj-$(CONFIG_ACPI_CONFIGFS) += acpi_configfs.o 106 107
+20
drivers/acpi/ac.c
··· 57 57 static int acpi_ac_remove(struct acpi_device *device); 58 58 static void acpi_ac_notify(struct acpi_device *device, u32 event); 59 59 60 + struct acpi_ac_bl { 61 + const char *hid; 62 + int hrv; 63 + }; 64 + 60 65 static const struct acpi_device_id ac_device_ids[] = { 61 66 {"ACPI0003", 0}, 62 67 {"", 0}, 63 68 }; 64 69 MODULE_DEVICE_TABLE(acpi, ac_device_ids); 70 + 71 + /* Lists of PMIC ACPI HIDs with an (often better) native charger driver */ 72 + static const struct acpi_ac_bl acpi_ac_blacklist[] = { 73 + { "INT33F4", -1 }, /* X-Powers AXP288 PMIC */ 74 + { "INT34D3", 3 }, /* Intel Cherrytrail Whiskey Cove PMIC */ 75 + }; 65 76 66 77 #ifdef CONFIG_PM_SLEEP 67 78 static int acpi_ac_resume(struct device *dev); ··· 435 424 436 425 static int __init acpi_ac_init(void) 437 426 { 427 + unsigned int i; 438 428 int result; 439 429 440 430 if (acpi_disabled) 441 431 return -ENODEV; 432 + 433 + for (i = 0; i < ARRAY_SIZE(acpi_ac_blacklist); i++) 434 + if (acpi_dev_present(acpi_ac_blacklist[i].hid, "1", 435 + acpi_ac_blacklist[i].hrv)) { 436 + pr_info(PREFIX "AC: found native %s PMIC, not loading\n", 437 + acpi_ac_blacklist[i].hid); 438 + return -ENODEV; 439 + } 442 440 443 441 #ifdef CONFIG_ACPI_PROCFS_POWER 444 442 acpi_ac_dir = acpi_lock_ac_dir();
+4 -1
drivers/acpi/acpi_platform.c
··· 121 121 if (IS_ERR(pdev)) 122 122 dev_err(&adev->dev, "platform device creation failed: %ld\n", 123 123 PTR_ERR(pdev)); 124 - else 124 + else { 125 + set_dev_node(&pdev->dev, acpi_get_node(adev->handle)); 125 126 dev_dbg(&adev->dev, "created platform device %s\n", 126 127 dev_name(&pdev->dev)); 128 + } 127 129 128 130 kfree(resources); 131 + 129 132 return pdev; 130 133 } 131 134 EXPORT_SYMBOL_GPL(acpi_create_platform_device);
-5
drivers/acpi/acpi_processor.c
··· 388 388 if (result) /* Processor is not physically present or unavailable */ 389 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 391 BUG_ON(pr->id >= nr_cpu_ids); 397 392 398 393 /*
+111 -46
drivers/acpi/acpi_video.c
··· 73 73 MODULE_PARM_DESC(report_key_events, 74 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 + */ 76 80 static bool device_id_scheme = false; 77 81 module_param(device_id_scheme, bool, 0444); 78 82 ··· 91 87 static int acpi_video_bus_remove(struct acpi_device *device); 92 88 static void acpi_video_bus_notify(struct acpi_device *device, u32 event); 93 89 void acpi_video_detect_exit(void); 90 + 91 + /* 92 + * Indices in the _BCL method response: the first two items are special, 93 + * the rest are all supported levels. 94 + * 95 + * See page 575 of the ACPI spec 3.0 96 + */ 97 + enum acpi_video_level_idx { 98 + ACPI_VIDEO_AC_LEVEL, /* level when machine has full power */ 99 + ACPI_VIDEO_BATTERY_LEVEL, /* level when machine is on batteries */ 100 + ACPI_VIDEO_FIRST_LEVEL, /* actual supported levels begin here */ 101 + }; 94 102 95 103 static const struct acpi_device_id video_device_ids[] = { 96 104 {ACPI_VIDEO_HID, 0}, ··· 148 132 the VGA device. */ 149 133 u32 pipe_id:3; /* For VGA multiple-head devices. */ 150 134 u32 reserved:10; /* Must be 0 */ 151 - u32 device_id_scheme:1; /* Device ID Scheme */ 135 + 136 + /* 137 + * The device ID might not actually follow the scheme described by this 138 + * struct acpi_video_device_attrib. If it does, then this bit 139 + * device_id_scheme is set; otherwise, other fields should be ignored. 140 + * 141 + * (but also see the global flag device_id_scheme) 142 + */ 143 + u32 device_id_scheme:1; 152 144 }; 153 145 154 146 struct acpi_video_enumerated_device { ··· 241 217 242 218 if (acpi_video_device_lcd_get_level_current(vd, &cur_level, false)) 243 219 return -EINVAL; 244 - for (i = 2; i < vd->brightness->count; i++) { 220 + for (i = ACPI_VIDEO_FIRST_LEVEL; i < vd->brightness->count; i++) { 245 221 if (vd->brightness->levels[i] == cur_level) 246 - /* 247 - * The first two entries are special - see page 575 248 - * of the ACPI spec 3.0 249 - */ 250 - return i - 2; 222 + return i - ACPI_VIDEO_FIRST_LEVEL; 251 223 } 252 224 return 0; 253 225 } 254 226 255 227 static int acpi_video_set_brightness(struct backlight_device *bd) 256 228 { 257 - int request_level = bd->props.brightness + 2; 229 + int request_level = bd->props.brightness + ACPI_VIDEO_FIRST_LEVEL; 258 230 struct acpi_video_device *vd = bl_get_data(bd); 259 231 260 232 cancel_delayed_work(&vd->switch_brightness_work); ··· 264 244 }; 265 245 266 246 /* thermal cooling device callbacks */ 267 - static int video_get_max_state(struct thermal_cooling_device *cooling_dev, unsigned 268 - long *state) 247 + static int video_get_max_state(struct thermal_cooling_device *cooling_dev, 248 + unsigned long *state) 269 249 { 270 250 struct acpi_device *device = cooling_dev->devdata; 271 251 struct acpi_video_device *video = acpi_driver_data(device); 272 252 273 - *state = video->brightness->count - 3; 253 + *state = video->brightness->count - ACPI_VIDEO_FIRST_LEVEL - 1; 274 254 return 0; 275 255 } 276 256 277 - static int video_get_cur_state(struct thermal_cooling_device *cooling_dev, unsigned 278 - long *state) 257 + static int video_get_cur_state(struct thermal_cooling_device *cooling_dev, 258 + unsigned long *state) 279 259 { 280 260 struct acpi_device *device = cooling_dev->devdata; 281 261 struct acpi_video_device *video = acpi_driver_data(device); ··· 284 264 285 265 if (acpi_video_device_lcd_get_level_current(video, &level, false)) 286 266 return -EINVAL; 287 - for (offset = 2; offset < video->brightness->count; offset++) 267 + for (offset = ACPI_VIDEO_FIRST_LEVEL; offset < video->brightness->count; 268 + offset++) 288 269 if (level == video->brightness->levels[offset]) { 289 270 *state = video->brightness->count - offset - 1; 290 271 return 0; ··· 301 280 struct acpi_video_device *video = acpi_driver_data(device); 302 281 int level; 303 282 304 - if (state >= video->brightness->count - 2) 283 + if (state >= video->brightness->count - ACPI_VIDEO_FIRST_LEVEL) 305 284 return -EINVAL; 306 285 307 286 state = video->brightness->count - state; ··· 366 345 } 367 346 368 347 device->brightness->curr = level; 369 - for (state = 2; state < device->brightness->count; state++) 348 + for (state = ACPI_VIDEO_FIRST_LEVEL; state < device->brightness->count; 349 + state++) 370 350 if (level == device->brightness->levels[state]) { 371 351 if (device->backlight) 372 - device->backlight->props.brightness = state - 2; 352 + device->backlight->props.brightness = 353 + state - ACPI_VIDEO_FIRST_LEVEL; 373 354 return 0; 374 355 } 375 356 ··· 553 530 554 531 if (device->brightness->flags._BQC_use_index) { 555 532 /* 556 - * _BQC returns an index that doesn't account for 557 - * the first 2 items with special meaning, so we need 558 - * to compensate for that by offsetting ourselves 533 + * _BQC returns an index that doesn't account for the first 2 534 + * items with special meaning (see enum acpi_video_level_idx), 535 + * so we need to compensate for that by offsetting ourselves 559 536 */ 560 537 if (device->brightness->flags._BCL_reversed) 561 - bqc_value = device->brightness->count - 3 - bqc_value; 538 + bqc_value = device->brightness->count - 539 + ACPI_VIDEO_FIRST_LEVEL - 1 - bqc_value; 562 540 563 - level = device->brightness->levels[bqc_value + 2]; 541 + level = device->brightness->levels[bqc_value + 542 + ACPI_VIDEO_FIRST_LEVEL]; 564 543 } else { 565 544 level = bqc_value; 566 545 } ··· 596 571 597 572 *level = acpi_video_bqc_value_to_level(device, *level); 598 573 599 - for (i = 2; i < device->brightness->count; i++) 574 + for (i = ACPI_VIDEO_FIRST_LEVEL; 575 + i < device->brightness->count; i++) 600 576 if (device->brightness->levels[i] == *level) { 601 577 device->brightness->curr = *level; 602 578 return 0; ··· 740 714 741 715 /* 742 716 * Some systems always report current brightness level as maximum 743 - * through _BQC, we need to test another value for them. 717 + * through _BQC, we need to test another value for them. However, 718 + * there is a subtlety: 719 + * 720 + * If the _BCL package ordering is descending, the first level 721 + * (br->levels[2]) is likely to be 0, and if the number of levels 722 + * matches the number of steps, we might confuse a returned level to 723 + * mean the index. 724 + * 725 + * For example: 726 + * 727 + * current_level = max_level = 100 728 + * test_level = 0 729 + * returned level = 100 730 + * 731 + * In this case 100 means the level, not the index, and _BCM failed. 732 + * Still, if the _BCL package ordering is descending, the index of 733 + * level 0 is also 100, so we assume _BQC is indexed, when it's not. 734 + * 735 + * This causes all _BQC calls to return bogus values causing weird 736 + * behavior from the user's perspective. For example: 737 + * 738 + * xbacklight -set 10; xbacklight -set 20; 739 + * 740 + * would flash to 90% and then slowly down to the desired level (20). 741 + * 742 + * The solution is simple; test anything other than the first level 743 + * (e.g. 1). 744 744 */ 745 - test_level = current_level == max_level ? br->levels[3] : max_level; 745 + test_level = current_level == max_level 746 + ? br->levels[ACPI_VIDEO_FIRST_LEVEL + 1] 747 + : max_level; 746 748 747 749 result = acpi_video_device_lcd_set_level(device, test_level); 748 750 if (result) ··· 784 730 /* buggy _BQC found, need to find out if it uses index */ 785 731 if (level < br->count) { 786 732 if (br->flags._BCL_reversed) 787 - level = br->count - 3 - level; 788 - if (br->levels[level + 2] == test_level) 733 + level = br->count - ACPI_VIDEO_FIRST_LEVEL - 1 - level; 734 + if (br->levels[level + ACPI_VIDEO_FIRST_LEVEL] == test_level) 789 735 br->flags._BQC_use_index = 1; 790 736 } 791 737 ··· 815 761 goto out; 816 762 } 817 763 818 - if (obj->package.count < 2) { 764 + if (obj->package.count < ACPI_VIDEO_FIRST_LEVEL) { 819 765 result = -EINVAL; 820 766 goto out; 821 767 } ··· 827 773 goto out; 828 774 } 829 775 830 - br->levels = kmalloc((obj->package.count + 2) * sizeof *(br->levels), 831 - GFP_KERNEL); 776 + /* 777 + * Note that we have to reserve 2 extra items (ACPI_VIDEO_FIRST_LEVEL), 778 + * in order to account for buggy BIOS which don't export the first two 779 + * special levels (see below) 780 + */ 781 + br->levels = kmalloc((obj->package.count + ACPI_VIDEO_FIRST_LEVEL) * 782 + sizeof(*br->levels), GFP_KERNEL); 832 783 if (!br->levels) { 833 784 result = -ENOMEM; 834 785 goto out_free; ··· 847 788 } 848 789 value = (u32) o->integer.value; 849 790 /* Skip duplicate entries */ 850 - if (count > 2 && br->levels[count - 1] == value) 791 + if (count > ACPI_VIDEO_FIRST_LEVEL 792 + && br->levels[count - 1] == value) 851 793 continue; 852 794 853 795 br->levels[count] = value; ··· 864 804 * In this case, the first two elements in _BCL packages 865 805 * are also supported brightness levels that OS should take care of. 866 806 */ 867 - for (i = 2; i < count; i++) { 868 - if (br->levels[i] == br->levels[0]) 807 + for (i = ACPI_VIDEO_FIRST_LEVEL; i < count; i++) { 808 + if (br->levels[i] == br->levels[ACPI_VIDEO_AC_LEVEL]) 869 809 level_ac_battery++; 870 - if (br->levels[i] == br->levels[1]) 810 + if (br->levels[i] == br->levels[ACPI_VIDEO_BATTERY_LEVEL]) 871 811 level_ac_battery++; 872 812 } 873 813 874 - if (level_ac_battery < 2) { 875 - level_ac_battery = 2 - level_ac_battery; 814 + if (level_ac_battery < ACPI_VIDEO_FIRST_LEVEL) { 815 + level_ac_battery = ACPI_VIDEO_FIRST_LEVEL - level_ac_battery; 876 816 br->flags._BCL_no_ac_battery_levels = 1; 877 - for (i = (count - 1 + level_ac_battery); i >= 2; i--) 817 + for (i = (count - 1 + level_ac_battery); 818 + i >= ACPI_VIDEO_FIRST_LEVEL; i--) 878 819 br->levels[i] = br->levels[i - level_ac_battery]; 879 820 count += level_ac_battery; 880 - } else if (level_ac_battery > 2) 821 + } else if (level_ac_battery > ACPI_VIDEO_FIRST_LEVEL) 881 822 ACPI_ERROR((AE_INFO, "Too many duplicates in _BCL package")); 882 823 883 824 /* Check if the _BCL package is in a reversed order */ 884 - if (max_level == br->levels[2]) { 825 + if (max_level == br->levels[ACPI_VIDEO_FIRST_LEVEL]) { 885 826 br->flags._BCL_reversed = 1; 886 - sort(&br->levels[2], count - 2, sizeof(br->levels[2]), 887 - acpi_video_cmp_level, NULL); 827 + sort(&br->levels[ACPI_VIDEO_FIRST_LEVEL], 828 + count - ACPI_VIDEO_FIRST_LEVEL, 829 + sizeof(br->levels[ACPI_VIDEO_FIRST_LEVEL]), 830 + acpi_video_cmp_level, NULL); 888 831 } else if (max_level != br->levels[count - 1]) 889 832 ACPI_ERROR((AE_INFO, 890 833 "Found unordered _BCL package")); ··· 957 894 * level_old is invalid (no matter whether it's a level 958 895 * or an index). Set the backlight to max_level in this case. 959 896 */ 960 - for (i = 2; i < br->count; i++) 897 + for (i = ACPI_VIDEO_FIRST_LEVEL; i < br->count; i++) 961 898 if (level == br->levels[i]) 962 899 break; 963 900 if (i == br->count || !level) ··· 969 906 goto out_free_levels; 970 907 971 908 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 972 - "found %d brightness levels\n", br->count - 2)); 909 + "found %d brightness levels\n", 910 + br->count - ACPI_VIDEO_FIRST_LEVEL)); 973 911 return 0; 974 912 975 913 out_free_levels: ··· 1361 1297 max = max_below = 0; 1362 1298 min = min_above = 255; 1363 1299 /* Find closest level to level_current */ 1364 - for (i = 2; i < device->brightness->count; i++) { 1300 + for (i = ACPI_VIDEO_FIRST_LEVEL; i < device->brightness->count; i++) { 1365 1301 l = device->brightness->levels[i]; 1366 1302 if (abs(l - level_current) < abs(delta)) { 1367 1303 delta = l - level_current; ··· 1371 1307 } 1372 1308 /* Ajust level_current to closest available level */ 1373 1309 level_current += delta; 1374 - for (i = 2; i < device->brightness->count; i++) { 1310 + for (i = ACPI_VIDEO_FIRST_LEVEL; i < device->brightness->count; i++) { 1375 1311 l = device->brightness->levels[i]; 1376 1312 if (l < min) 1377 1313 min = l; ··· 1744 1680 1745 1681 memset(&props, 0, sizeof(struct backlight_properties)); 1746 1682 props.type = BACKLIGHT_FIRMWARE; 1747 - props.max_brightness = device->brightness->count - 3; 1683 + props.max_brightness = 1684 + device->brightness->count - ACPI_VIDEO_FIRST_LEVEL - 1; 1748 1685 device->backlight = backlight_device_register(name, 1749 1686 parent, 1750 1687 device,
+20 -2
drivers/acpi/battery.c
··· 67 67 MODULE_LICENSE("GPL"); 68 68 69 69 static async_cookie_t async_cookie; 70 + static bool battery_driver_registered; 70 71 static int battery_bix_broken_package; 71 72 static int battery_notification_delay_ms; 72 73 static unsigned int cache_time = 1000; ··· 93 92 }; 94 93 95 94 MODULE_DEVICE_TABLE(acpi, battery_device_ids); 95 + 96 + /* Lists of PMIC ACPI HIDs with an (often better) native battery driver */ 97 + static const char * const acpi_battery_blacklist[] = { 98 + "INT33F4", /* X-Powers AXP288 PMIC */ 99 + }; 96 100 97 101 enum { 98 102 ACPI_BATTERY_ALARM_PRESENT, ··· 1321 1315 1322 1316 static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie) 1323 1317 { 1318 + unsigned int i; 1324 1319 int result; 1320 + 1321 + for (i = 0; i < ARRAY_SIZE(acpi_battery_blacklist); i++) 1322 + if (acpi_dev_present(acpi_battery_blacklist[i], "1", -1)) { 1323 + pr_info(PREFIX ACPI_BATTERY_DEVICE_NAME 1324 + ": found native %s PMIC, not loading\n", 1325 + acpi_battery_blacklist[i]); 1326 + return; 1327 + } 1325 1328 1326 1329 dmi_check_system(bat_dmi_table); 1327 1330 ··· 1344 1329 if (result < 0) 1345 1330 acpi_unlock_battery_dir(acpi_battery_dir); 1346 1331 #endif 1332 + battery_driver_registered = (result == 0); 1347 1333 } 1348 1334 1349 1335 static int __init acpi_battery_init(void) ··· 1359 1343 static void __exit acpi_battery_exit(void) 1360 1344 { 1361 1345 async_synchronize_cookie(async_cookie + 1); 1362 - acpi_bus_unregister_driver(&acpi_battery_driver); 1346 + if (battery_driver_registered) 1347 + acpi_bus_unregister_driver(&acpi_battery_driver); 1363 1348 #ifdef CONFIG_ACPI_PROCFS_POWER 1364 - acpi_unlock_battery_dir(acpi_battery_dir); 1349 + if (acpi_battery_dir) 1350 + acpi_unlock_battery_dir(acpi_battery_dir); 1365 1351 #endif 1366 1352 } 1367 1353
+8
drivers/acpi/blacklist.c
··· 188 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 199 #endif 192 200 {} 193 201 };
+44 -36
drivers/acpi/cppc_acpi.c
··· 132 132 133 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 + 152 + show_cppc_data(cppc_get_perf_caps, cppc_perf_caps, highest_perf); 153 + show_cppc_data(cppc_get_perf_caps, cppc_perf_caps, lowest_perf); 154 + show_cppc_data(cppc_get_perf_caps, cppc_perf_caps, nominal_perf); 155 + show_cppc_data(cppc_get_perf_caps, cppc_perf_caps, lowest_nonlinear_perf); 156 + show_cppc_data(cppc_get_perf_ctrs, cppc_perf_fb_ctrs, reference_perf); 157 + show_cppc_data(cppc_get_perf_ctrs, cppc_perf_fb_ctrs, wraparound_time); 158 + 135 159 static ssize_t show_feedback_ctrs(struct kobject *kobj, 136 160 struct attribute *attr, char *buf) 137 161 { 138 162 struct cpc_desc *cpc_ptr = to_cpc_desc(kobj); 139 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 170 return scnprintf(buf, PAGE_SIZE, "ref:%llu del:%llu\n", 144 171 fb_ctrs.reference, fb_ctrs.delivered); 145 172 } 146 173 define_one_cppc_ro(feedback_ctrs); 147 174 148 - static 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 - } 159 - define_one_cppc_ro(reference_perf); 160 - 161 - static 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 - } 172 - define_one_cppc_ro(wraparound_time); 173 - 174 175 static struct attribute *cppc_attrs[] = { 175 176 &feedback_ctrs.attr, 176 177 &reference_perf.attr, 177 178 &wraparound_time.attr, 179 + &highest_perf.attr, 180 + &lowest_perf.attr, 181 + &lowest_nonlinear_perf.attr, 182 + &nominal_perf.attr, 178 183 NULL 179 184 }; 180 185 ··· 977 972 int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps) 978 973 { 979 974 struct cpc_desc *cpc_desc = per_cpu(cpc_desc_ptr, cpunum); 980 - struct cpc_register_resource *highest_reg, *lowest_reg, *ref_perf, 981 - *nom_perf; 982 - u64 high, low, nom; 975 + struct cpc_register_resource *highest_reg, *lowest_reg, 976 + *lowest_non_linear_reg, *nominal_reg; 977 + u64 high, low, nom, min_nonlinear; 983 978 int ret = 0, regs_in_pcc = 0; 984 979 985 980 if (!cpc_desc) { ··· 989 984 990 985 highest_reg = &cpc_desc->cpc_regs[HIGHEST_PERF]; 991 986 lowest_reg = &cpc_desc->cpc_regs[LOWEST_PERF]; 992 - ref_perf = &cpc_desc->cpc_regs[REFERENCE_PERF]; 993 - nom_perf = &cpc_desc->cpc_regs[NOMINAL_PERF]; 987 + lowest_non_linear_reg = &cpc_desc->cpc_regs[LOW_NON_LINEAR_PERF]; 988 + nominal_reg = &cpc_desc->cpc_regs[NOMINAL_PERF]; 994 989 995 990 /* Are any of the regs PCC ?*/ 996 991 if (CPC_IN_PCC(highest_reg) || CPC_IN_PCC(lowest_reg) || 997 - CPC_IN_PCC(ref_perf) || CPC_IN_PCC(nom_perf)) { 992 + CPC_IN_PCC(lowest_non_linear_reg) || CPC_IN_PCC(nominal_reg)) { 998 993 regs_in_pcc = 1; 999 994 down_write(&pcc_data.pcc_lock); 1000 995 /* Ring doorbell once to update PCC subspace */ ··· 1010 1005 cpc_read(cpunum, lowest_reg, &low); 1011 1006 perf_caps->lowest_perf = low; 1012 1007 1013 - cpc_read(cpunum, nom_perf, &nom); 1008 + cpc_read(cpunum, nominal_reg, &nom); 1014 1009 perf_caps->nominal_perf = nom; 1015 1010 1016 - if (!high || !low || !nom) 1011 + cpc_read(cpunum, lowest_non_linear_reg, &min_nonlinear); 1012 + perf_caps->lowest_nonlinear_perf = min_nonlinear; 1013 + 1014 + if (!high || !low || !nom || !min_nonlinear) 1017 1015 ret = -EFAULT; 1018 1016 1019 1017 out_err: ··· 1091 1083 perf_fb_ctrs->delivered = delivered; 1092 1084 perf_fb_ctrs->reference = reference; 1093 1085 perf_fb_ctrs->reference_perf = ref_perf; 1094 - perf_fb_ctrs->ctr_wrap_time = ctr_wrap_time; 1086 + perf_fb_ctrs->wraparound_time = ctr_wrap_time; 1095 1087 out_err: 1096 1088 if (regs_in_pcc) 1097 1089 up_write(&pcc_data.pcc_lock);
-2
drivers/acpi/internal.h
··· 65 65 #endif 66 66 int acpi_rev_override_setup(char *str); 67 67 68 - extern bool acpi_force_hot_remove; 69 - 70 68 void acpi_sysfs_add_hotplug_profile(struct acpi_hotplug_profile *hotplug, 71 69 const char *name); 72 70 int acpi_scan_add_handler_with_hotplug(struct acpi_scan_handler *handler,
+280
drivers/acpi/pmic/intel_pmic_chtwc.c
··· 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 + */ 81 + static 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 + 224 + static 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 + 236 + static 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 + */ 246 + static 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 + 253 + static 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 + 263 + static struct platform_device_id cht_wc_opregion_id_table[] = { 264 + { .name = "cht_wcove_region" }, 265 + {}, 266 + }; 267 + MODULE_DEVICE_TABLE(platform, cht_wc_opregion_id_table); 268 + 269 + static 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 + }; 276 + module_platform_driver(intel_cht_wc_pmic_opregion_driver); 277 + 278 + MODULE_DESCRIPTION("Intel CHT Whiskey Cove PMIC operation region driver"); 279 + MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>"); 280 + MODULE_LICENSE("GPL");
+4 -17
drivers/acpi/pmic/intel_pmic_xpower.c
··· 18 18 #include <linux/mfd/axp20x.h> 19 19 #include <linux/regmap.h> 20 20 #include <linux/platform_device.h> 21 - #include <linux/iio/consumer.h> 22 21 #include "intel_pmic.h" 23 22 24 23 #define XPOWER_GPADC_LOW 0x5b ··· 185 186 * @regmap: regmap of the PMIC device 186 187 * @reg: register to get the reading 187 188 * 188 - * We could get the sensor value by manipulating the HW regs here, but since 189 - * the axp288 IIO driver may also access the same regs at the same time, the 190 - * APIs provided by IIO subsystem are used here instead to avoid problems. As 191 - * a result, the two passed in params are of no actual use. 192 - * 193 189 * Return a positive value on success, errno on failure. 194 190 */ 195 191 static int intel_xpower_pmic_get_raw_temp(struct regmap *regmap, int reg) 196 192 { 197 - struct iio_channel *gpadc_chan; 198 - int ret, val; 193 + u8 buf[2]; 199 194 200 - gpadc_chan = iio_channel_get(NULL, "axp288-system-temp"); 201 - if (IS_ERR_OR_NULL(gpadc_chan)) 202 - return -EACCES; 195 + if (regmap_bulk_read(regmap, AXP288_GP_ADC_H, buf, 2)) 196 + return -EIO; 203 197 204 - ret = iio_read_channel_raw(gpadc_chan, &val); 205 - if (ret < 0) 206 - val = ret; 207 - 208 - iio_channel_release(gpadc_chan); 209 - return val; 198 + return (buf[0] << 4) + ((buf[1] >> 4) & 0x0F); 210 199 } 211 200 212 201 static struct intel_pmic_opregion_data intel_xpower_pmic_opregion_data = {
+8 -16
drivers/acpi/scan.c
··· 30 30 31 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 - */ 37 - bool acpi_force_hot_remove; 38 - 39 33 static const char *dummy_hid = "device"; 40 34 41 35 static LIST_HEAD(acpi_dep_list); ··· 164 170 pn->put_online = false; 165 171 } 166 172 ret = device_offline(pn->dev); 167 - if (acpi_force_hot_remove) 168 - continue; 169 - 170 173 if (ret >= 0) { 171 174 pn->put_online = !ret; 172 175 } else { ··· 232 241 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX, 233 242 NULL, acpi_bus_offline, (void *)true, 234 243 (void **)&errdev); 235 - if (!errdev || acpi_force_hot_remove) 244 + if (!errdev) 236 245 acpi_bus_offline(handle, 0, (void *)true, 237 246 (void **)&errdev); 238 247 239 - if (errdev && !acpi_force_hot_remove) { 248 + if (errdev) { 240 249 dev_warn(errdev, "Offline failed.\n"); 241 250 acpi_bus_online(handle, 0, NULL, NULL); 242 251 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ··· 254 263 unsigned long long sta; 255 264 acpi_status status; 256 265 257 - if (device->handler && device->handler->hotplug.demand_offline 258 - && !acpi_force_hot_remove) { 266 + if (device->handler && device->handler->hotplug.demand_offline) { 259 267 if (!acpi_scan_is_offline(device, true)) 260 268 return -EBUSY; 261 269 } else { ··· 1840 1850 device->flags.power_manageable = 0; 1841 1851 1842 1852 device->flags.initialized = true; 1853 + } else if (device->flags.visited) { 1854 + goto ok; 1843 1855 } 1844 1856 1845 1857 ret = acpi_scan_attach_handler(device); ··· 1858 1866 if (ret < 0) 1859 1867 return; 1860 1868 1861 - if (ret > 0 || !device->pnp.type.platform_id) 1862 - acpi_device_set_enumerated(device); 1863 - else 1869 + if (device->pnp.type.platform_id) 1864 1870 acpi_default_enumeration(device); 1871 + else 1872 + acpi_device_set_enumerated(device); 1865 1873 1866 1874 ok: 1867 1875 list_for_each_entry(child, &device->children, node)
+5 -4
drivers/acpi/sysfs.c
··· 921 921 static ssize_t force_remove_show(struct kobject *kobj, 922 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 927 927 static ssize_t force_remove_store(struct kobject *kobj, ··· 935 935 if (ret < 0) 936 936 return ret; 937 937 938 - lock_device_hotplug(); 939 - acpi_force_hot_remove = val; 940 - unlock_device_hotplug(); 938 + if (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 + return -EINVAL; 941 + } 941 942 return size; 942 943 } 943 944
-16
drivers/acpi/tables.c
··· 311 311 } 312 312 313 313 int __init 314 - acpi_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 - 329 - int __init 330 314 acpi_table_parse_entries_array(char *id, 331 315 unsigned long table_size, 332 316 struct acpi_subtable_proc *proc, int proc_num,
+66
drivers/acpi/utils.c
··· 736 736 } 737 737 EXPORT_SYMBOL(acpi_dev_found); 738 738 739 + struct acpi_dev_present_info { 740 + struct acpi_device_id hid[2]; 741 + const char *uid; 742 + s64 hrv; 743 + }; 744 + 745 + static 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 + */ 789 + bool 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 + } 803 + EXPORT_SYMBOL(acpi_dev_present); 804 + 739 805 /* 740 806 * acpi_backlight= handling, this is done here rather then in video_detect.c 741 807 * because __setup cannot be used in modules.
+18 -10
drivers/power/supply/axp288_charger.c
··· 14 14 * GNU General Public License for more details. 15 15 */ 16 16 17 + #include <linux/acpi.h> 17 18 #include <linux/module.h> 18 19 #include <linux/device.h> 19 20 #include <linux/regmap.h> ··· 114 113 #define ILIM_3000MA 3000 /* 3000mA */ 115 114 116 115 #define AXP288_EXTCON_DEV_NAME "axp288_extcon" 117 - #define USB_HOST_EXTCON_DEV_NAME "INT3496:00" 116 + #define USB_HOST_EXTCON_HID "INT3496" 117 + #define USB_HOST_EXTCON_NAME "INT3496:00" 118 118 119 119 static const unsigned int cable_ids[] = 120 120 { EXTCON_CHG_USB_SDP, EXTCON_CHG_USB_CDP, EXTCON_CHG_USB_DCP }; ··· 809 807 return -EPROBE_DEFER; 810 808 } 811 809 812 - info->otg.cable = extcon_get_extcon_dev(USB_HOST_EXTCON_DEV_NAME); 813 - if (info->otg.cable == NULL) { 814 - dev_dbg(dev, "EXTCON_USB_HOST is not ready, probe deferred\n"); 815 - return -EPROBE_DEFER; 810 + if (acpi_dev_present(USB_HOST_EXTCON_HID, NULL, -1)) { 811 + info->otg.cable = extcon_get_extcon_dev(USB_HOST_EXTCON_NAME); 812 + if (info->otg.cable == NULL) { 813 + dev_dbg(dev, "EXTCON_USB_HOST is not ready, probe deferred\n"); 814 + return -EPROBE_DEFER; 815 + } 816 + dev_info(&pdev->dev, 817 + "Using " USB_HOST_EXTCON_HID " extcon for usb-id\n"); 816 818 } 817 819 818 820 platform_set_drvdata(pdev, info); ··· 855 849 /* Register for OTG notification */ 856 850 INIT_WORK(&info->otg.work, axp288_charger_otg_evt_worker); 857 851 info->otg.id_nb.notifier_call = axp288_charger_handle_otg_evt; 858 - ret = devm_extcon_register_notifier(&pdev->dev, info->otg.cable, 852 + if (info->otg.cable) { 853 + ret = devm_extcon_register_notifier(&pdev->dev, info->otg.cable, 859 854 EXTCON_USB_HOST, &info->otg.id_nb); 860 - if (ret) { 861 - dev_err(dev, "failed to register EXTCON_USB_HOST notifier\n"); 862 - return ret; 855 + if (ret) { 856 + dev_err(dev, "failed to register EXTCON_USB_HOST notifier\n"); 857 + return ret; 858 + } 859 + schedule_work(&info->otg.work); 863 860 } 864 - schedule_work(&info->otg.work); 865 861 866 862 /* Register charger interrupts */ 867 863 for (i = 0; i < CHRG_INTR_END; i++) {
+1
include/acpi/acpi_bus.h
··· 88 88 } 89 89 90 90 bool acpi_dev_found(const char *hid); 91 + bool acpi_dev_present(const char *hid, const char *uid, s64 hrv); 91 92 92 93 #ifdef CONFIG_ACPI 93 94
+2 -1
include/acpi/cppc_acpi.h
··· 103 103 u32 highest_perf; 104 104 u32 nominal_perf; 105 105 u32 lowest_perf; 106 + u32 lowest_nonlinear_perf; 106 107 }; 107 108 108 109 struct cppc_perf_ctrls { ··· 116 115 u64 reference; 117 116 u64 delivered; 118 117 u64 reference_perf; 119 - u64 ctr_wrap_time; 118 + u64 wraparound_time; 120 119 }; 121 120 122 121 /* Per CPU container for runtime CPPC management. */
+5 -4
include/linux/acpi.h
··· 233 233 234 234 int acpi_table_init (void); 235 235 int acpi_table_parse(char *id, acpi_tbl_table_handler handler); 236 - int __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); 240 236 int __init acpi_table_parse_entries(char *id, unsigned long table_size, 241 237 int entry_id, 242 238 acpi_tbl_entry_handler handler, ··· 603 607 struct fwnode_handle; 604 608 605 609 static inline bool acpi_dev_found(const char *hid) 610 + { 611 + return false; 612 + } 613 + 614 + static inline bool acpi_dev_present(const char *hid, const char *uid, s64 hrv) 606 615 { 607 616 return false; 608 617 }