diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2017-04-21 15:12:57 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2017-04-21 15:12:57 -0400 |
commit | 8494206dc5587c3204d12965c88cbf5f726ef94d (patch) | |
tree | 46b428cf2eaa06f345b687d43833f8116c4b4b28 | |
parent | fe8c470ab87d90e4b5115902dd94eced7e3305c3 (diff) | |
parent | 6c4c9a9a4a294a2e85784d0eaf6a4f833ee99752 (diff) |
Merge back power-related ACPI material for v4.12.
-rw-r--r-- | drivers/acpi/ac.c | 20 | ||||
-rw-r--r-- | drivers/acpi/battery.c | 22 | ||||
-rw-r--r-- | drivers/acpi/utils.c | 66 | ||||
-rw-r--r-- | drivers/power/supply/axp288_charger.c | 28 | ||||
-rw-r--r-- | include/acpi/acpi_bus.h | 1 | ||||
-rw-r--r-- | include/linux/acpi.h | 5 |
6 files changed, 130 insertions, 12 deletions
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); | |||
57 | static int acpi_ac_remove(struct acpi_device *device); | 57 | static int acpi_ac_remove(struct acpi_device *device); |
58 | static void acpi_ac_notify(struct acpi_device *device, u32 event); | 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 | static const struct acpi_device_id ac_device_ids[] = { | 65 | static const struct acpi_device_id ac_device_ids[] = { |
61 | {"ACPI0003", 0}, | 66 | {"ACPI0003", 0}, |
62 | {"", 0}, | 67 | {"", 0}, |
63 | }; | 68 | }; |
64 | MODULE_DEVICE_TABLE(acpi, ac_device_ids); | 69 | MODULE_DEVICE_TABLE(acpi, ac_device_ids); |
65 | 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 | }; | ||
76 | |||
66 | #ifdef CONFIG_PM_SLEEP | 77 | #ifdef CONFIG_PM_SLEEP |
67 | static int acpi_ac_resume(struct device *dev); | 78 | static 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 | ||
425 | static int __init acpi_ac_init(void) | 436 | static 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/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"); | |||
67 | MODULE_LICENSE("GPL"); | 67 | MODULE_LICENSE("GPL"); |
68 | 68 | ||
69 | static async_cookie_t async_cookie; | 69 | static async_cookie_t async_cookie; |
70 | static bool battery_driver_registered; | ||
70 | static int battery_bix_broken_package; | 71 | static int battery_bix_broken_package; |
71 | static int battery_notification_delay_ms; | 72 | static int battery_notification_delay_ms; |
72 | static unsigned int cache_time = 1000; | 73 | static unsigned int cache_time = 1000; |
@@ -93,6 +94,11 @@ static const struct acpi_device_id battery_device_ids[] = { | |||
93 | 94 | ||
94 | MODULE_DEVICE_TABLE(acpi, battery_device_ids); | 95 | MODULE_DEVICE_TABLE(acpi, battery_device_ids); |
95 | 96 | ||
97 | /* Lists of PMIC ACPI HIDs with an (often better) native battery driver */ | ||
98 | static const char * const acpi_battery_blacklist[] = { | ||
99 | "INT33F4", /* X-Powers AXP288 PMIC */ | ||
100 | }; | ||
101 | |||
96 | enum { | 102 | enum { |
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 | ||
1316 | static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie) | 1322 | static 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 | ||
1334 | static int __init acpi_battery_init(void) | 1350 | static int __init acpi_battery_init(void) |
@@ -1343,9 +1359,11 @@ static int __init acpi_battery_init(void) | |||
1343 | static void __exit acpi_battery_exit(void) | 1359 | static 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/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 | } |
737 | EXPORT_SYMBOL(acpi_dev_found); | 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 | * 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 | ||
118 | static const unsigned int cable_ids[] = | 120 | static 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 | ||
90 | bool acpi_dev_found(const char *hid); | 90 | bool acpi_dev_found(const char *hid); |
91 | bool 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/linux/acpi.h b/include/linux/acpi.h index 9b05886f9773..841a8dc55ade 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h | |||
@@ -611,6 +611,11 @@ static inline bool acpi_dev_found(const char *hid) | |||
611 | return false; | 611 | return false; |
612 | } | 612 | } |
613 | 613 | ||
614 | static inline bool acpi_dev_present(const char *hid, const char *uid, s64 hrv) | ||
615 | { | ||
616 | return false; | ||
617 | } | ||
618 | |||
614 | static inline bool is_acpi_node(struct fwnode_handle *fwnode) | 619 | static inline bool is_acpi_node(struct fwnode_handle *fwnode) |
615 | { | 620 | { |
616 | return false; | 621 | return false; |