aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-04-21 15:12:57 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-04-21 15:12:57 -0400
commit8494206dc5587c3204d12965c88cbf5f726ef94d (patch)
tree46b428cf2eaa06f345b687d43833f8116c4b4b28
parentfe8c470ab87d90e4b5115902dd94eced7e3305c3 (diff)
parent6c4c9a9a4a294a2e85784d0eaf6a4f833ee99752 (diff)
Merge back power-related ACPI material for v4.12.
-rw-r--r--drivers/acpi/ac.c20
-rw-r--r--drivers/acpi/battery.c22
-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/linux/acpi.h5
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);
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/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/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/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
614static inline bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
615{
616 return false;
617}
618
614static inline bool is_acpi_node(struct fwnode_handle *fwnode) 619static inline bool is_acpi_node(struct fwnode_handle *fwnode)
615{ 620{
616 return false; 621 return false;