From a3bcf2d45d6a9c7950f58ec7dad20f22d422abd2 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Fri, 17 Jun 2016 16:01:08 +0300 Subject: tools/acpi: use CROSS_COMPILE to define prefix CROSS_COMPILE can be considered as standard definition for toolchain prefix when cross-compiling. Use it here. Signed-off-by: Andy Shevchenko Signed-off-by: Rafael J. Wysocki --- tools/power/acpi/Makefile.config | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/power/acpi/Makefile.config b/tools/power/acpi/Makefile.config index 552af68d5414..a538ff44b108 100644 --- a/tools/power/acpi/Makefile.config +++ b/tools/power/acpi/Makefile.config @@ -54,9 +54,10 @@ INSTALL_SCRIPT = ${INSTALL_PROGRAM} # to something more interesting, like "arm-linux-". If you want # to compile vs uClibc, that can be done here as well. CROSS = #/usr/i386-linux-uclibc/usr/bin/i386-uclibc- -CC = $(CROSS)gcc -LD = $(CROSS)gcc -STRIP = $(CROSS)strip +CROSS_COMPILE ?= $(CROSS) +CC = $(CROSS_COMPILE)gcc +LD = $(CROSS_COMPILE)gcc +STRIP = $(CROSS_COMPILE)strip HOSTCC = gcc # check if compiler option is supported -- cgit v1.2.3-59-g8ed1b From 0f093e95f5b631f35ef7a131a7a9ef48748e2623 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Mon, 11 Jul 2016 16:23:26 -0400 Subject: ACPI / dock: make dock explicitly non-modular The Kconfig for this file is: drivers/acpi/Kconfig:config ACPI_DOCK drivers/acpi/Kconfig: bool "Dock" ...and so it is not built as a module. Hence including module.h and everything that comes with it just for the no-op MODULE_LICENSE and friends is rather heavy handed. The license/author info is found at the top of the file, so we just remove the MODULE_LICENSE etc and the include of module.h The file does still have some module_param() so we add the right include for that infrastructure. Signed-off-by: Paul Gortmaker Signed-off-by: Rafael J. Wysocki --- drivers/acpi/dock.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c index e8e128dede29..0c00208b423e 100644 --- a/drivers/acpi/dock.c +++ b/drivers/acpi/dock.c @@ -21,7 +21,7 @@ */ #include -#include +#include #include #include #include @@ -33,12 +33,7 @@ #include "internal.h" -#define ACPI_DOCK_DRIVER_DESCRIPTION "ACPI Dock Station Driver" - ACPI_MODULE_NAME("dock"); -MODULE_AUTHOR("Kristen Carlson Accardi"); -MODULE_DESCRIPTION(ACPI_DOCK_DRIVER_DESCRIPTION); -MODULE_LICENSE("GPL"); static bool immediate_undock = 1; module_param(immediate_undock, bool, 0644); -- cgit v1.2.3-59-g8ed1b From c49b43ce03944bb7cfb75f8a4f8f6ba799fa517e Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Mon, 11 Jul 2016 17:22:41 -0400 Subject: ACPI / lpat: make it explicitly non-modular The Makefile for building this is "acpi-y" and so it is not built as a module. Hence including module.h and everything that comes with it just for the no-op MODULE_LICENSE is rather heavy handed. The license info is found at the top of the file, so we just remove the MODULE_LICENSE and the include of module.h We add an include of export.h since the file exports some symbols. Signed-off-by: Paul Gortmaker Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpi_lpat.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/acpi/acpi_lpat.c b/drivers/acpi/acpi_lpat.c index feb61c1630eb..c1c4877ca96c 100644 --- a/drivers/acpi/acpi_lpat.c +++ b/drivers/acpi/acpi_lpat.c @@ -13,7 +13,7 @@ * GNU General Public License for more details. */ -#include +#include #include #include @@ -157,5 +157,3 @@ void acpi_lpat_free_conversion_table(struct acpi_lpat_conversion_table } } EXPORT_SYMBOL_GPL(acpi_lpat_free_conversion_table); - -MODULE_LICENSE("GPL"); -- cgit v1.2.3-59-g8ed1b From 6256ebd5daf93505f12b66916fb1b961b38f4cf2 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Sun, 17 Jul 2016 13:45:32 -0700 Subject: ACPI / DPTF: Add DPTF power participant driver This driver adds support for Dynamic Platform and Thermal Framework (DPTF) Platform Power Participant device (INT3407) support. This participant is responsible for exposing platform telemetry such as: max_platform_power platform_power_source adapter_rating battery_steady_power charger_type These attributes are presented via sysfs interface under the INT3407 platform device: $ls /sys/bus/platform/devices/INT3407\:00/dptf_power/ adapter_rating_mw battery_steady_power_mw charger_type max_platform_power_mw platform_power_source ` ACPI methods description used in this driver: PMAX: Maximum platform power that can be supported by the battery in mW. PSRC: System charge source, 0x00 = DC 0x01 = AC 0x02 = USB 0x03 = Wireless Charger ARTG: Adapter rating in mW (Maximum Adapter power) Must be 0 if no AC adapter is plugged in. CTYP: Charger Type, Traditional : 0x01 Hybrid: 0x02 NVDC: 0x03 PBSS: Returns max sustained power for battery in milliWatts. The INT3407 also contains _BTS and _BIX objects, which are compliant to ACPI 5.0, specification. Those objects are already used by ACPI battery (PNP0C0A) driver and information about them is exported via Linux power supply class registration. Signed-off-by: Srinivas Pandruvada Signed-off-by: Rafael J. Wysocki --- drivers/acpi/Kconfig | 1 + drivers/acpi/Makefile | 1 + drivers/acpi/dptf/Kconfig | 15 +++++ drivers/acpi/dptf/Makefile | 1 + drivers/acpi/dptf/dptf_power.c | 128 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 146 insertions(+) create mode 100644 drivers/acpi/dptf/Kconfig create mode 100644 drivers/acpi/dptf/Makefile create mode 100644 drivers/acpi/dptf/dptf_power.c diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index b7e2e776397d..b91a35bfc999 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig @@ -475,6 +475,7 @@ config ACPI_NFIT_DEBUG issue. source "drivers/acpi/apei/Kconfig" +source "drivers/acpi/dptf/Kconfig" config ACPI_EXTLOG tristate "Extended Error Log support" diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 251ce85a66fb..f6d0cc0fb4e1 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -101,3 +101,4 @@ obj-$(CONFIG_CRC_PMIC_OPREGION) += pmic/intel_pmic_crc.o obj-$(CONFIG_XPOWER_PMIC_OPREGION) += pmic/intel_pmic_xpower.o video-objs += acpi_video.o video_detect.o +obj-y += dptf/ diff --git a/drivers/acpi/dptf/Kconfig b/drivers/acpi/dptf/Kconfig new file mode 100644 index 000000000000..ac0a6ed0cf46 --- /dev/null +++ b/drivers/acpi/dptf/Kconfig @@ -0,0 +1,15 @@ +config DPTF_POWER + tristate "DPTF Platform Power Participant" + depends on X86 + help + This driver adds support for Dynamic Platform and Thermal Framework + (DPTF) Platform Power Participant device (INT3407) support. + This participant is responsible for exposing platform telemetry: + max_platform_power + platform_power_source + adapter_rating + battery_steady_power + charger_type + + To compile this driver as a module, choose M here: + the module will be called dptf_power. diff --git a/drivers/acpi/dptf/Makefile b/drivers/acpi/dptf/Makefile new file mode 100644 index 000000000000..62cbe8753a19 --- /dev/null +++ b/drivers/acpi/dptf/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_DPTF_POWER) += dptf_power.o diff --git a/drivers/acpi/dptf/dptf_power.c b/drivers/acpi/dptf/dptf_power.c new file mode 100644 index 000000000000..734642dc5008 --- /dev/null +++ b/drivers/acpi/dptf/dptf_power.c @@ -0,0 +1,128 @@ +/* + * dptf_power: DPTF platform power driver + * Copyright (c) 2016, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + */ + +#include +#include +#include +#include + +/* + * Presentation of attributes which are defined for INT3407. They are: + * PMAX : Maximum platform powe + * PSRC : Platform power source + * ARTG : Adapter rating + * CTYP : Charger type + * PBSS : Battery steady power + */ +#define DPTF_POWER_SHOW(name, object) \ +static ssize_t name##_show(struct device *dev,\ + struct device_attribute *attr,\ + char *buf)\ +{\ + struct platform_device *pdev = to_platform_device(dev);\ + struct acpi_device *acpi_dev = platform_get_drvdata(pdev);\ + unsigned long long val;\ + acpi_status status;\ +\ + status = acpi_evaluate_integer(acpi_dev->handle, #object,\ + NULL, &val);\ + if (ACPI_SUCCESS(status))\ + return sprintf(buf, "%d\n", (int)val);\ + else \ + return -EINVAL;\ +} + +DPTF_POWER_SHOW(max_platform_power_mw, PMAX) +DPTF_POWER_SHOW(platform_power_source, PSRC) +DPTF_POWER_SHOW(adapter_rating_mw, ARTG) +DPTF_POWER_SHOW(battery_steady_power_mw, PBSS) +DPTF_POWER_SHOW(charger_type, CTYP) + +static DEVICE_ATTR_RO(max_platform_power_mw); +static DEVICE_ATTR_RO(platform_power_source); +static DEVICE_ATTR_RO(adapter_rating_mw); +static DEVICE_ATTR_RO(battery_steady_power_mw); +static DEVICE_ATTR_RO(charger_type); + +static struct attribute *dptf_power_attrs[] = { + &dev_attr_max_platform_power_mw.attr, + &dev_attr_platform_power_source.attr, + &dev_attr_adapter_rating_mw.attr, + &dev_attr_battery_steady_power_mw.attr, + &dev_attr_charger_type.attr, + NULL +}; + +static struct attribute_group dptf_power_attribute_group = { + .attrs = dptf_power_attrs, + .name = "dptf_power" +}; + +static int dptf_power_add(struct platform_device *pdev) +{ + struct acpi_device *acpi_dev; + acpi_status status; + unsigned long long ptype; + int result; + + acpi_dev = ACPI_COMPANION(&(pdev->dev)); + if (!acpi_dev) + return -ENODEV; + + status = acpi_evaluate_integer(acpi_dev->handle, "PTYP", NULL, &ptype); + if (ACPI_FAILURE(status)) + return -ENODEV; + + if (ptype != 0x11) + return -ENODEV; + + result = sysfs_create_group(&pdev->dev.kobj, + &dptf_power_attribute_group); + if (result) + return result; + + platform_set_drvdata(pdev, acpi_dev); + + return 0; +} + +static int dptf_power_remove(struct platform_device *pdev) +{ + + sysfs_remove_group(&pdev->dev.kobj, &dptf_power_attribute_group); + + return 0; +} + +static const struct acpi_device_id int3407_device_ids[] = { + {"INT3407", 0}, + {"", 0}, +}; +MODULE_DEVICE_TABLE(acpi, int3407_device_ids); + +static struct platform_driver dptf_power_driver = { + .probe = dptf_power_add, + .remove = dptf_power_remove, + .driver = { + .name = "DPTF Platform Power", + .acpi_match_table = int3407_device_ids, + }, +}; + +module_platform_driver(dptf_power_driver); + +MODULE_AUTHOR("Srinivas Pandruvada "); +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("ACPI DPTF platform power driver"); -- cgit v1.2.3-59-g8ed1b From c11dd70fd7f50fca7dc05520ec8075f12d93cb63 Mon Sep 17 00:00:00 2001 From: Srinivas Pandruvada Date: Tue, 19 Jul 2016 14:57:49 -0700 Subject: ACPI / DPTF: move int340x_thermal.c to the DPTF folder Since DPTF has its own folder under ACPI, move this file also there. Signed-off-by: Srinivas Pandruvada Signed-off-by: Rafael J. Wysocki --- drivers/acpi/Makefile | 1 - drivers/acpi/dptf/Makefile | 3 +++ drivers/acpi/dptf/int340x_thermal.c | 53 +++++++++++++++++++++++++++++++++++++ drivers/acpi/int340x_thermal.c | 53 ------------------------------------- 4 files changed, 56 insertions(+), 54 deletions(-) create mode 100644 drivers/acpi/dptf/int340x_thermal.c delete mode 100644 drivers/acpi/int340x_thermal.c diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index f6d0cc0fb4e1..0325a539b1c8 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile @@ -44,7 +44,6 @@ acpi-y += acpi_lpss.o acpi_apd.o acpi-y += acpi_platform.o acpi-y += acpi_pnp.o acpi-$(CONFIG_ARM_AMBA) += acpi_amba.o -acpi-y += int340x_thermal.o acpi-y += power.o acpi-y += event.o acpi-$(CONFIG_ACPI_REDUCED_HARDWARE_ONLY) += evged.o diff --git a/drivers/acpi/dptf/Makefile b/drivers/acpi/dptf/Makefile index 62cbe8753a19..06ea8809583d 100644 --- a/drivers/acpi/dptf/Makefile +++ b/drivers/acpi/dptf/Makefile @@ -1 +1,4 @@ +obj-$(CONFIG_ACPI) += int340x_thermal.o obj-$(CONFIG_DPTF_POWER) += dptf_power.o + +ccflags-y += -Idrivers/acpi diff --git a/drivers/acpi/dptf/int340x_thermal.c b/drivers/acpi/dptf/int340x_thermal.c new file mode 100644 index 000000000000..33505c651f62 --- /dev/null +++ b/drivers/acpi/dptf/int340x_thermal.c @@ -0,0 +1,53 @@ +/* + * ACPI support for int340x thermal drivers + * + * Copyright (C) 2014, Intel Corporation + * Authors: Zhang Rui + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include + +#include "internal.h" + +#define INT3401_DEVICE 0X01 +static const struct acpi_device_id int340x_thermal_device_ids[] = { + {"INT3400"}, + {"INT3401", INT3401_DEVICE}, + {"INT3402"}, + {"INT3403"}, + {"INT3404"}, + {"INT3406"}, + {"INT3407"}, + {"INT3408"}, + {"INT3409"}, + {"INT340A"}, + {"INT340B"}, + {""}, +}; + +static int int340x_thermal_handler_attach(struct acpi_device *adev, + const struct acpi_device_id *id) +{ + if (IS_ENABLED(CONFIG_INT340X_THERMAL)) + acpi_create_platform_device(adev); + /* Intel SoC DTS thermal driver needs INT3401 to set IRQ descriptor */ + else if (IS_ENABLED(CONFIG_INTEL_SOC_DTS_THERMAL) && + id->driver_data == INT3401_DEVICE) + acpi_create_platform_device(adev); + return 1; +} + +static struct acpi_scan_handler int340x_thermal_handler = { + .ids = int340x_thermal_device_ids, + .attach = int340x_thermal_handler_attach, +}; + +void __init acpi_int340x_thermal_init(void) +{ + acpi_scan_add_handler(&int340x_thermal_handler); +} diff --git a/drivers/acpi/int340x_thermal.c b/drivers/acpi/int340x_thermal.c deleted file mode 100644 index 33505c651f62..000000000000 --- a/drivers/acpi/int340x_thermal.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * ACPI support for int340x thermal drivers - * - * Copyright (C) 2014, Intel Corporation - * Authors: Zhang Rui - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#include -#include - -#include "internal.h" - -#define INT3401_DEVICE 0X01 -static const struct acpi_device_id int340x_thermal_device_ids[] = { - {"INT3400"}, - {"INT3401", INT3401_DEVICE}, - {"INT3402"}, - {"INT3403"}, - {"INT3404"}, - {"INT3406"}, - {"INT3407"}, - {"INT3408"}, - {"INT3409"}, - {"INT340A"}, - {"INT340B"}, - {""}, -}; - -static int int340x_thermal_handler_attach(struct acpi_device *adev, - const struct acpi_device_id *id) -{ - if (IS_ENABLED(CONFIG_INT340X_THERMAL)) - acpi_create_platform_device(adev); - /* Intel SoC DTS thermal driver needs INT3401 to set IRQ descriptor */ - else if (IS_ENABLED(CONFIG_INTEL_SOC_DTS_THERMAL) && - id->driver_data == INT3401_DEVICE) - acpi_create_platform_device(adev); - return 1; -} - -static struct acpi_scan_handler int340x_thermal_handler = { - .ids = int340x_thermal_device_ids, - .attach = int340x_thermal_handler_attach, -}; - -void __init acpi_int340x_thermal_init(void) -{ - acpi_scan_add_handler(&int340x_thermal_handler); -} -- cgit v1.2.3-59-g8ed1b