Thermal: ACPI INT340X thermal drivers
Subsystems (6)
Zhang Rui
reviewercover Thermal: ACPI INT340X thermal drivers
Hi,
Newer laptops and tablets that use ACPI may have thermal sensors and other devices with thermal control capabilities outside the core CPU/SOC, for thermal safety reasons.
They are exposed for the OS to use via the ACPI INT340x device objects.
This patch set introduces kernel drivers for those INT340X devices and expose their telemetry and cooling capability to user space via the normal thermal framework. So that a wide range of applications and GUI widgets can show this information to the user or use this information for making decisions. For example, the Intel Thermal Daemon can use this information to allow the user to select his laptop to run w/ or w/o turning on the fans.
thanks,
rui
----------------------------------------------------------------
Aaron Lu (9):
ACPI / fan: remove unused macro
ACPI / fan: remove no need check for device pointer
ACPI / fan: use acpi_device_xxx_power instead of acpi_bus equivelant ACPI / fan: convert to platform driver
ACPI / Fan: add ACPI 4.0 style fan support
ACPI / Fan: support INT3404 thermal device
Thermal: move the KELVIN_TO_MILLICELSIUS macro to thermal.h
Thermal: introduce INT3402 thermal driver
Thermal: introduce INT3406 thermal driver
Jacob Pan (2):
Thermal: int340x_thermal: expose acpi thermal relationship tables
Thermal: int3400_thermal: use acpi_thermal_rel parsing APIs
Lan Tianyu (1):
Thermal: introduce int3403 thermal driver
Zhang Rui (7):
ACPI: introduce ACPI int340x thermal scan handler
ACPI: make acpi_create_platform_device() an external API
ACPI: add ACPI_TYPE_LOCAL_REFERENCE support to acpi_extract_package()
Thermal: introduce int3400 thermal driver
Thermal: int3400 thermal: add capability to detect supporting UUIDs
Thermal: int3400 thermal: register to thermal framework
Thermal: int340x thermal: select ACPI fan driver
drivers/acpi/Kconfig | 2 +- drivers/acpi/Makefile | 1 + drivers/acpi/acpi_platform.c | 1 + drivers/acpi/device_pm.c | 1 + drivers/acpi/fan.c | 341 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------- drivers/acpi/int340x_thermal.c | 51 ++++++++++++++++ drivers/acpi/internal.h | 3 +- drivers/acpi/scan.c | 1 + drivers/acpi/thermal.c | 18 +++--- drivers/acpi/utils.c | 28 ++++++++- drivers/acpi/video.c | 78 +++++++++++++----------- drivers/thermal/Kconfig | 39 +++++++----- drivers/thermal/Makefile | 2 +- drivers/thermal/int3403_thermal.c | 296 ---------------------------------------------------------------------------------------- drivers/thermal/int340x_thermal/Makefile | 5 ++ drivers/thermal/int340x_thermal/acpi_thermal_rel.c | 400 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/thermal/int340x_thermal/acpi_thermal_rel.h | 84 +++++++++++++++++++++++++ drivers/thermal/int340x_thermal/int3400_thermal.c | 271 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/thermal/int340x_thermal/int3402_thermal.c | 242 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/thermal/int340x_thermal/int3403_thermal.c | 489 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/thermal/int340x_thermal/int3406_thermal.c | 230 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/video/backlight/backlight.c | 44 +++++++++----- include/acpi/acpi_bus.h | 1 + include/acpi/video.h | 20 ++++++ include/linux/acpi.h | 7 +++ include/linux/backlight.h | 2 + include/linux/thermal.h | 4 ++ 27 files changed, 2208 insertions(+), 453 deletions(-) create mode 100644 drivers/acpi/int340x_thermal.c delete mode 100644 drivers/thermal/int3403_thermal.c create mode 100644 drivers/thermal/int340x_thermal/Makefile create mode 100644 drivers/thermal/int340x_thermal/acpi_thermal_rel.c create mode 100644 drivers/thermal/int340x_thermal/acpi_thermal_rel.h create mode 100644 drivers/thermal/int340x_thermal/int3400_thermal.c create mode 100644 drivers/thermal/int340x_thermal/int3402_thermal.c create mode 100644 drivers/thermal/int340x_thermal/int3403_thermal.c create mode 100644 drivers/thermal/int340x_thermal/int3406_thermal.c
Zhang Rui
reviewerPATCH 1/19 ACPI: introduce ACPI int340x thermal scan handler
Newer laptops and tablets that use ACPI may have thermal sensors and other devices with thermal control capabilities outside the core CPU/SOC, for thermal safety reasons.
They are exposed for the OS to use via
1) INT3400 ACPI device object as the master.
2) INT3401 ~ INT340B ACPI device objects as the slaves.
This patch introduces a scan handler to enumerate the INT3400 ACPI device object to platform bus, and prevent its slaves from being enumerated before the controller driver being probed.
--- drivers/acpi/Makefile | 1 + drivers/acpi/int340x_thermal.c | 51 ++++++++++++++++++++++++++++++++++++++++++ drivers/acpi/internal.h | 1 + drivers/acpi/scan.c | 1 + drivers/thermal/Kconfig | 17 ++++++++++++++ 5 files changed, 71 insertions(+) create mode 100644 drivers/acpi/int340x_thermal.c
drivers/acpi/Makefile +1 -0
@@ -43,6 +43,7 @@ acpi-y += pci_root.o pci_link.o pci_irq.o acpi-y += acpi_lpss.o acpi-y += acpi_platform.o acpi-y += acpi_pnp.o +acpi-y += int340x_thermal.o acpi-y += power.o acpi-y += event.o acpi-y += sysfs.o
drivers/acpi/int340x_thermal.c new file +51 -0
51 lines not on this page · raw message
drivers/acpi/internal.h +1 -0
@@ -31,6 +31,7 @@ void acpi_pci_link_init(void);void acpi_processor_init (void );void acpi_platform_init (void );void acpi_pnp_init (void ); +void acpi_int340x_thermal_init (void );int acpi_sysfs_init (void );void acpi_container_init (void );void acpi_memory_hotplug_init (void );
drivers/acpi/scan.c +1 -0
@@ -2306,6 +2306,7 @@ int __init acpi_scan_init(void)acpi_container_init ();acpi_memory_hotplug_init ();acpi_pnp_init (); +acpi_int340x_thermal_init ();mutex_lock (&acpi_scan_lock);/*
drivers/thermal/Kconfig +17 -0
@@ -234,6 +234,23 @@ config INTEL_SOC_DTS_THERMAL notification methods.The other trip is a critical trip point, which was set by the driver based on the TJ MAX temperature. +config INT340X_THERMAL + bool + depends on X86 && ACPI + help + Newer laptops and tablets that use ACPI may have thermal sensors and + other devices with thermal control capabilities outside the core + CPU/SOC, for thermal safety reasons. + They are exposed for the OS to use via the INT3400 ACPI device object + as the master, and INT3401~INT340B ACPI device objects as the slaves. + Enable this to expose the temperature information and cooling ability + from these objects to userspace via the normal thermal framework. + This means that a wide range of applications and GUI widgets can show + the information to the user or use this information for making + decisions. For example, the Intel Thermal Daemon can use this + information to allow the user to select his laptop to run without + turning on the fans. + menu "Texas Instruments thermal drivers" source "drivers/thermal/ti-soc-thermal/Kconfig" endmenu
Signature · 1 line
1.8.3.2
Re: [PATCH 01/19] ACPI: introduce ACPI int340x thermal scan handler
Quoted 7 lines · Zhang Rui
Newer laptops and tablets that use ACPI may have thermal sensors and other devices with thermal control capabilities outside the core CPU/SOC, for thermal safety reasons.
They are exposed for the OS to use via
1) INT3400 ACPI device object as the master.
2) INT3401 ~ INT340B ACPI device objects as the slaves.
Quoted 5 lines
This patch introduces a scan handler to enumerate the INT3400 ACPI device object to platform bus, and prevent its slaves from being enumerated before the controller driver being probed.
Signed-off-by Zhang Rui <[email protected]>
ACK
Quoted 131 lines
--- drivers/acpi/Makefile | 1 + drivers/acpi/int340x_thermal.c | 51 ++++++++++++++++++++++++++++++++++++++++++ drivers/acpi/internal.h | 1 + drivers/acpi/scan.c | 1 + drivers/thermal/Kconfig | 17 ++++++++++++++ 5 files changed, 71 insertions(+) create mode 100644 drivers/acpi/int340x_thermal.cdrivers/acpi/Makefile +1
-0@@ -43,6 +43,7 @@ acpi-y += pci_root.o pci_link.o pci_irq.o acpi-y += acpi_lpss.o acpi-y += acpi_platform.o acpi-y += acpi_pnp.o +acpi-y += int340x_thermal.o acpi-y += power.o acpi-y += event.o acpi-y += sysfs.odrivers/acpi/int340x_thermal.c new file +51
-0@@ -0,0 +1,51 @@ +/* +* ACPI support for int340x thermal drivers +* +* Copyright (C) 2014, Intel Corporation +* Authors: Zhang Rui <[email protected]> +* +* 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 <linux/acpi.h> +#include <linux/module.h> + +#include "internal.h" + +#define DO_ENUMERATION 0x01 +static const struct acpi_device_id int340x_thermal_device_ids[] = { + {"INT3400" ,DO_ENUMERATION }, + {"INT3401" }, + {"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) +{ +#ifdef CONFIG_INT340X_THERMAL +if (id->driver_data ==DO_ENUMERATION ) +acpi_create_platform_device (adev); +#endif +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); +}drivers/acpi/internal.h +1
-0@@ -31,6 +31,7 @@ void acpi_pci_link_init(void);void acpi_processor_init (void );void acpi_platform_init (void );void acpi_pnp_init (void ); +void acpi_int340x_thermal_init (void );int acpi_sysfs_init (void );void acpi_container_init (void );void acpi_memory_hotplug_init (void );drivers/acpi/scan.c +1
-0@@ -2306,6 +2306,7 @@ int __init acpi_scan_init(void)acpi_container_init ();acpi_memory_hotplug_init ();acpi_pnp_init (); +acpi_int340x_thermal_init ();mutex_lock (&acpi_scan_lock);/* drivers/thermal/Kconfig +17
-0@@ -234,6 +234,23 @@ config INTEL_SOC_DTS_THERMAL notification methods.The other trip is a critical trip point, which was set by the driver based on the TJ MAX temperature. +config INT340X_THERMAL + bool + depends on X86 && ACPI + help + Newer laptops and tablets that use ACPI may have thermal sensors and + other devices with thermal control capabilities outside the core + CPU/SOC, for thermal safety reasons. + They are exposed for the OS to use via the INT3400 ACPI device object + as the master, and INT3401~INT340B ACPI device objects as the slaves. + Enable this to expose the temperature information and cooling ability + from these objects to userspace via the normal thermal framework. + This means that a wide range of applications and GUI widgets can show + the information to the user or use this information for making + decisions. For example, the Intel Thermal Daemon can use this + information to allow the user to select his laptop to run without + turning on the fans. + menu "Texas Instruments thermal drivers" source "drivers/thermal/ti-soc-thermal/Kconfig" endmenu
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Zhang Rui
reviewerPATCH 2/19 ACPI: make acpi_create_platform_device() an external API
In reply to Zhang Rui--- drivers/acpi/acpi_platform.c | 1 + include/linux/acpi.h | 7 +++++++ 2 files changed, 8 insertions(+)
drivers/acpi/acpi_platform.c +1 -0
@@ -113,3 +113,4 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev)kfree (resources);return pdev; } +EXPORT_SYMBOL_GPL (acpi_create_platform_device);
include/linux/acpi.h +7 -0
@@ -432,6 +432,7 @@ static inline bool acpi_driver_match_device(struct device *dev,int acpi_device_uevent_modalias (struct device *,struct kobj_uevent_env *);int acpi_device_modalias (struct device *,char *,int ); +struct platform_device *acpi_create_platform_device (struct acpi_device *);#define ACPI_PTR (_ptr) (_ptr)#else /* !CONFIG_ACPI */
@@ -523,6 +524,12 @@ static inline int acpi_device_modalias(struct device *dev, return -ENODEV; } +static inline struct platform_device *acpi_create_platform_device ( +struct acpi_device *) +{ +return NULL ; +} +#define ACPI_PTR (_ptr) (NULL)#endif /* !CONFIG_ACPI */
Signature · 1 line
1.8.3.2
Re: [PATCH 02/19] ACPI: make acpi_create_platform_device() an external API
Quoted 20 lines · Zhang Rui
Signed-off-by Zhang Rui <[email protected]>--- drivers/acpi/acpi_platform.c | 1 + include/linux/acpi.h | 7 +++++++ 2 files changed, 8 insertions(+)drivers/acpi/acpi_platform.c +1
-0@@ -113,3 +113,4 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev)kfree (resources);return pdev; } +EXPORT_SYMBOL_GPL (acpi_create_platform_device);include/linux/acpi.h +0
-0
include/linux/acpi.h static inline bool acpi_driver_match_device(struct device *dev, · line 435
Quoted 4 lines
include/linux/acpi.h +1
-0@@ -432,6 +432,7 @@ static inline bool acpi_driver_match_device(struct device *dev,int acpi_device_uevent_modalias (struct device *,struct kobj_uevent_env *);int acpi_device_modalias (struct device *,char *,int ); +struct platform_device *acpi_create_platform_device (struct acpi_device *);
But then please drop the header from internal.h.
Quoted 17 lines
include/linux/acpi.h +6
-0#define ACPI_PTR (_ptr) (_ptr)#else /* !CONFIG_ACPI */ @@ -523,6 +524,12 @@ static inline int acpi_device_modalias(struct device *dev, return -ENODEV; } +static inline struct platform_device *acpi_create_platform_device ( +struct acpi_device *) +{ +return NULL ; +} +#define ACPI_PTR (_ptr) (NULL)#endif /* !CONFIG_ACPI */
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Zhang Rui
reviewerPATCH 3/19 ACPI: add ACPI_TYPE_LOCAL_REFERENCE support to acpi_extract_package()
In reply to Zhang RuiAdd ACPI_TYPE_LOCAL_REFERENCE support to acpi_extract_package(), so that we can use this helper for more cases like _ART/_TRT.
--- drivers/acpi/utils.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
drivers/acpi/utils.c +27 -1
@@ -149,6 +149,21 @@ acpi_extract_package(union acpi_object *package,break ; }break ; +case ACPI_TYPE_LOCAL_REFERENCE : +switch (format_string[i]) { +case 'R' : + size_required +=sizeof (void *); + tail_offset +=sizeof (void *); +break ; +default : + printk(KERN_WARNING PREFIX "Invalid package element" +" [%d] got reference," +" expecting [%c]\n" , + i, format_string[i]); +return AE_BAD_DATA ; +break ; + } +break ;case ACPI_TYPE_PACKAGE :default :
@@ -247,7 +262,18 @@ acpi_extract_package(union acpi_object *package,break ; }break ; - +case ACPI_TYPE_LOCAL_REFERENCE : +switch (format_string[i]) { +case 'R' : + *(void **)head = + (void *)element->reference.handle; + head +=sizeof (void *); +break ; +default : +/* Should never get here */ +break ; + } +break ;case ACPI_TYPE_PACKAGE :/* TBD: handle nested packages... */ default :
Signature · 1 line
1.8.3.2
Re: [PATCH 03/19] ACPI: add ACPI_TYPE_LOCAL_REFERENCE support to acpi_extract_package()
Quoted 4 lines · Zhang Rui
Add
ACPI_TYPE_LOCAL_REFERENCEsupport toacpi_extract_package(), so that we can use this helper for more cases like _ART/_TRT.Signed-off-by Zhang Rui <[email protected]>
ACK
Quoted 51 lines
--- drivers/acpi/utils.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)drivers/acpi/utils.c +27
-1@@ -149,6 +149,21 @@ acpi_extract_package(union acpi_object *package,break ; }break ; +case ACPI_TYPE_LOCAL_REFERENCE : +switch (format_string[i]) { +case 'R' : + size_required +=sizeof (void *); + tail_offset +=sizeof (void *); +break ; +default : + printk(KERN_WARNING PREFIX "Invalid package element" +" [%d] got reference," +" expecting [%c]\n" , + i, format_string[i]); +return AE_BAD_DATA ; +break ; + } +break ;case ACPI_TYPE_PACKAGE :default :@@ -247,7 +262,18 @@ acpi_extract_package(union acpi_object *package,break ; }break ; - +case ACPI_TYPE_LOCAL_REFERENCE : +switch (format_string[i]) { +case 'R' : + *(void **)head = + (void *)element->reference.handle; + head +=sizeof (void *); +break ; +default : +/* Should never get here */ +break ; + } +break ;case ACPI_TYPE_PACKAGE :/* TBD: handle nested packages... */ default :
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Zhang Rui
reviewerPATCH 4/19 Thermal: introduce int3400 thermal driver
In reply to Zhang RuiIntroduce int3400 thermal driver. And make INT3400 driver enumerate the other int340x thermal components shown in _ART/_TRT.
--- drivers/acpi/int340x_thermal.c | 2 +- drivers/thermal/Kconfig | 2 +- drivers/thermal/Makefile | 1 + drivers/thermal/int340x_thermal/Makefile | 1 + drivers/thermal/int340x_thermal/int3400_thermal.c | 245 ++++++++++++++++++++++ 5 files changed, 249 insertions(+), 2 deletions(-) create mode 100644 drivers/thermal/int340x_thermal/Makefile create mode 100644 drivers/thermal/int340x_thermal/int3400_thermal.c
drivers/acpi/int340x_thermal.c +1 -1
@@ -33,7 +33,7 @@ static const struct acpi_device_id int340x_thermal_device_ids[] = {static int int340x_thermal_handler_attach (struct acpi_device *adev,const struct acpi_device_id *id) { -#ifdef CONFIG_INT340X_THERMAL +#if defined(CONFIG_INT340X_THERMAL ) || defined(CONFIG_INT340X_THERMAL_MODULE )if (id->driver_data ==DO_ENUMERATION )acpi_create_platform_device (adev);#endif
drivers/thermal/Kconfig +1 -1
@@ -235,7 +235,7 @@ config INTEL_SOC_DTS_THERMAL was set by the driver based on the TJ MAX temperature. config INT340X_THERMAL - bool + tristate "ACPI INT340X thermal drivers" depends on X86 && ACPI help Newer laptops and tablets that use ACPI may have thermal sensors and
drivers/thermal/Makefile +1 -0
@@ -32,4 +32,5 @@ obj-$(CONFIG_X86_PKG_TEMP_THERMAL) += x86_pkg_temp_thermal.o obj-$(CONFIG_INTEL_SOC_DTS_THERMAL) += intel_soc_dts_thermal.o obj-$(CONFIG_TI_SOC_THERMAL) += ti-soc-thermal/ obj-$(CONFIG_ACPI_INT3403_THERMAL) += int3403_thermal.o +obj-$(CONFIG_INT340X_THERMAL) += int340x_thermal/ obj-$(CONFIG_ST_THERMAL) += st/
drivers/thermal/int340x_thermal/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_INT340X_THERMAL) += int3400_thermal.o
drivers/thermal/int340x_thermal/int3400_thermal.c new file +245 -0
245 lines not on this page · raw message
Signature · 1 line
1.8.3.2
Zhang Rui
reviewerPATCH 5/19 Thermal: int3400 thermal: add capability to detect supporting UUIDs
In reply to Zhang Rui--- drivers/thermal/int340x_thermal/int3400_thermal.c | 69 +++++++++++++++++++++++ 1 file changed, 69 insertions(+)
drivers/thermal/int340x_thermal/int3400_thermal.c +69 -0
@@ -41,14 +41,79 @@ struct trt {u64 reverved4; }; +enum int3400_thermal_uuid { +INT3400_THERMAL_PASSIVE_1 , +INT3400_THERMAL_PASSIVE_2 , +INT3400_THERMAL_ACTIVE , +INT3400_THERMAL_CRITICAL , +INT3400_THERMAL_COOLING_MODE , +INT3400_THERMAL_MAXIMUM_UUID , +}; + +static u8 *int3400_thermal_uuids[INT3400_THERMAL_MAXIMUM_UUID ] = { +"42A441D6-AE6A-462b-A84B-4A8CE79027D3" , +"9E04115A-AE87-4D1C-9500-0F3E340BFE75" , +"3A95C389-E4B8-4629-A526-C52C88626BAE" , +"97C68AE7-15FA-499c-B8C9-5DA81D606E0A" , +"16CAF1B7-DD38-40ed-B1C1-1B8A1913D531" , +}; +struct int3400_thermal_priv {struct acpi_device *adev;int art_count;struct art *arts;int trt_count;struct trt *trts; +u8 uuid_bitmap; }; +static int int3400_thermal_get_uuids (struct int3400_thermal_priv *priv) +{ +struct acpi_buffer buf = {ACPI_ALLOCATE_BUFFER ,NULL }; +union acpi_object *obja, *objb; +int i, j; +int result =0 ; +acpi_status status; + + status =acpi_evaluate_object (priv->adev->handle,"IDSP" ,NULL , &buf); +if (ACPI_FAILURE (status)) +return -ENODEV ; + + obja = (union acpi_object *)buf.pointer; +if (obja->type !=ACPI_TYPE_PACKAGE ) { + result = -EINVAL ; + goto end; + } + +for (i =0 ; i < obja->package.count; i++) { + objb = &obja->package.elements[i]; +if (objb->type !=ACPI_TYPE_BUFFER ) { + result = -EINVAL ; + goto end; + } + +/* UUID must be 16 bytes */ +if (objb->buffer.length !=16 ) { + result = -EINVAL ; + goto end; + } + +for (j =0 ; j <INT3400_THERMAL_MAXIMUM_UUID ; j++) { +u8 uuid[16 ]; + +acpi_str_to_uuid (int3400_thermal_uuids[j], uuid); +if (!strncmp (uuid, objb->buffer.pointer,16 )) { + priv->uuid_bitmap |= (1 << j); +break ; + } + } + } + +end: +kfree (buf.pointer); +return result; +} +static int parse_art (struct int3400_thermal_priv *priv) {acpi_handle handle = priv->adev->handle;
@@ -193,6 +258,10 @@ static int int3400_thermal_probe(struct platform_device *pdev) priv->adev = adev; + result =int3400_thermal_get_uuids (priv); +if (result) + goto free_priv; + result =parse_art (priv);if (result) goto free_priv;
Signature · 1 line
1.8.3.2
Zhang Rui
reviewerPATCH 6/19 Thermal: int3400 thermal: register to thermal framework
In reply to Zhang Rui--- drivers/thermal/Kconfig | 1 + drivers/thermal/int340x_thermal/int3400_thermal.c | 103 ++++++++++++++++++++++ 2 files changed, 104 insertions(+)
drivers/thermal/Kconfig +1 -0
@@ -237,6 +237,7 @@ config INTEL_SOC_DTS_THERMAL config INT340X_THERMAL tristate "ACPI INT340X thermal drivers" depends on X86 && ACPI + select THERMAL_GOV_USER_SPACE help Newer laptops and tablets that use ACPI may have thermal sensors and other devices with thermal control capabilities outside the core
drivers/thermal/int340x_thermal/int3400_thermal.c +103 -0
140 lines not on this page · raw message
Signature · 1 line
1.8.3.2
Zhang Rui
reviewerPATCH 7/19 ACPI / fan: remove unused macro
In reply to Zhang RuiFrom: Aaron Lu <[email protected]>
The _COMPONENT, ACPI_MODULE_NAME(name) and ACPI_FAN_FILE_STATE are not used anywhere so remove them.
--- drivers/acpi/fan.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/acpi/fan.c +0 -4
@@ -34,10 +34,6 @@#define PREFIX "ACPI: "#define ACPI_FAN_CLASS "fan" -#define ACPI_FAN_FILE_STATE "state" - -#define _COMPONENT ACPI_FAN_COMPONENT -ACPI_MODULE_NAME ("fan" );MODULE_AUTHOR ("Paul Diefenbaugh" );MODULE_DESCRIPTION ("ACPI Fan Driver" );
Signature · 1 line
1.8.3.2
Zhang Rui
reviewerPATCH 8/19 ACPI / fan: remove no need check for device pointer
In reply to Zhang RuiFrom: Aaron Lu <[email protected]>
The device pointer will not be NULL in the PM callback and ACPI driver's add/remove callback, so checking NULL for them isn't necessary.
--- drivers/acpi/fan.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-)
drivers/acpi/fan.c +1 -17
@@ -131,9 +131,6 @@ static int acpi_fan_add(struct acpi_device *device)int result =0 ;struct thermal_cooling_device *cdev; -if (!device) -return -EINVAL ; -strcpy (acpi_device_name (device),"Fan" );strcpy (acpi_device_class (device),ACPI_FAN_CLASS );
@@ -177,14 +174,7 @@ static int acpi_fan_add(struct acpi_device *device)static int acpi_fan_remove (struct acpi_device *device) { -struct thermal_cooling_device *cdev; - -if (!device) -return -EINVAL ; - - cdev =acpi_driver_data (device); -if (!cdev) -return -EINVAL ; +struct thermal_cooling_device *cdev =acpi_driver_data (device);sysfs_remove_link (&device->dev.kobj,"thermal_cooling" );sysfs_remove_link (&cdev->device.kobj,"device" );
@@ -196,9 +186,6 @@ static int acpi_fan_remove(struct acpi_device *device)#ifdef CONFIG_PM_SLEEP static int acpi_fan_suspend (struct device *dev) { -if (!dev) -return -EINVAL ; -acpi_bus_set_power (to_acpi_device (dev)->handle,ACPI_STATE_D0 );return AE_OK ;
@@ -208,9 +195,6 @@ static int acpi_fan_resume(struct device *dev) {int result; -if (!dev) -return -EINVAL ; - result =acpi_bus_update_power (to_acpi_device (dev)->handle,NULL );if (result) printk(KERN_ERR PREFIX "Error updating fan power state\n");
Signature · 1 line
1.8.3.2
Zhang Rui
reviewerPATCH 9/19 ACPI / fan: use acpi_device_xxx_power instead of acpi_bus equivelant
In reply to Zhang RuiFrom: Aaron Lu <[email protected]>
When we have the acpi_device pointer, there is no need to pass the device's handle to the acpi_bus_xxx_power functions to get/set/update the device's power state, instead, use the acpi_device_xxx_power functions directly.
To make this happen for fan module, export acpi_device_update_power.
--- drivers/acpi/device_pm.c | 1 + drivers/acpi/fan.c | 10 +++++----- drivers/acpi/internal.h | 2 -- include/acpi/acpi_bus.h | 1 + 4 files changed, 7 insertions(+), 7 deletions(-)
drivers/acpi/device_pm.c +1 -0
@@ -343,6 +343,7 @@ int acpi_device_update_power(struct acpi_device *device, int *state_p)return 0 ; } +EXPORT_SYMBOL_GPL (acpi_device_update_power);int acpi_bus_update_power (acpi_handle handle,int *state_p) {
drivers/acpi/fan.c +5 -5
@@ -92,7 +92,7 @@ static int fan_get_cur_state(struct thermal_cooling_device *cdev, unsigned longif (!device)return -EINVAL ; - result =acpi_bus_update_power (device->handle, &acpi_state); + result =acpi_device_update_power (device, &acpi_state);if (result)return result;
@@ -110,7 +110,7 @@ fan_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)if (!device || (state !=0 && state !=1 ))return -EINVAL ; - result =acpi_bus_set_power (device->handle, + result =acpi_device_set_power (device, state ?ACPI_STATE_D0 :ACPI_STATE_D3_COLD );return result;
@@ -134,7 +134,7 @@ static int acpi_fan_add(struct acpi_device *device)strcpy (acpi_device_name (device),"Fan" );strcpy (acpi_device_class (device),ACPI_FAN_CLASS ); - result =acpi_bus_update_power (device->handle,NULL ); + result =acpi_device_update_power (device,NULL );if (result) { printk(KERN_ERR PREFIX "Setting initial power state\n"); goto end;
@@ -186,7 +186,7 @@ static int acpi_fan_remove(struct acpi_device *device)#ifdef CONFIG_PM_SLEEP static int acpi_fan_suspend (struct device *dev) { -acpi_bus_set_power (to_acpi_device (dev)->handle,ACPI_STATE_D0 ); +acpi_device_set_power (to_acpi_device (dev),ACPI_STATE_D0 );return AE_OK ; }
@@ -195,7 +195,7 @@ static int acpi_fan_resume(struct device *dev) {int result; - result =acpi_bus_update_power (to_acpi_device (dev)->handle,NULL ); + result =acpi_device_update_power (to_acpi_device (dev),NULL );if (result) printk(KERN_ERR PREFIX "Error updating fan power state\n");
drivers/acpi/internal.h +0 -2
@@ -104,8 +104,6 @@ int acpi_power_get_inferred_state(struct acpi_device *device, int *state);int acpi_power_on_resources (struct acpi_device *device,int state);int acpi_power_transition (struct acpi_device *device,int state); -int acpi_device_update_power (struct acpi_device *device,int *state_p); -int acpi_wakeup_device_init (void );#ifdef CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC
include/acpi/acpi_bus.h +1 -0
@@ -435,6 +435,7 @@ int acpi_device_set_power(struct acpi_device *device, int state);int acpi_bus_init_power (struct acpi_device *device);int acpi_device_fix_up_power (struct acpi_device *device);int acpi_bus_update_power (acpi_handle handle,int *state_p); +int acpi_device_update_power (struct acpi_device *device,int *state_p);bool acpi_bus_power_manageable (acpi_handle handle);#ifdef CONFIG_PM
Signature · 1 line
1.8.3.2
Zhang Rui
reviewerPATCH 10/19 ACPI / fan: convert to platform driver
In reply to Zhang RuiFrom: Aaron Lu <[email protected]>
Convert ACPI fan driver to a platform driver for the purpose of phasing out ACPI bus.
--- drivers/acpi/fan.c | 62 ++++++++++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 34 deletions(-)
drivers/acpi/fan.c +28 -34
@@ -30,17 +30,14 @@#include <asm/uaccess.h> #include <linux/thermal.h> #include <linux/acpi.h> - -#define PREFIX "ACPI: " - -#define ACPI_FAN_CLASS "fan" +#include <linux/platform_device.h> MODULE_AUTHOR ("Paul Diefenbaugh" );MODULE_DESCRIPTION ("ACPI Fan Driver" );MODULE_LICENSE ("GPL" ); -static int acpi_fan_add (struct acpi_device *device); -static int acpi_fan_remove (struct acpi_device *device); +static int acpi_fan_probe (struct platform_device *pdev); +static int acpi_fan_remove (struct platform_device *pdev);static const struct acpi_device_id fan_device_ids[] = { {"PNP0C0B" ,0 },
@@ -62,15 +59,14 @@ static struct dev_pm_ops acpi_fan_pm = {#define FAN_PM_OPS_PTR NULL#endif -static struct acpi_driver acpi_fan_driver = { - .name ="fan" , - .class =ACPI_FAN_CLASS , - .ids = fan_device_ids, - .ops = { - .add = acpi_fan_add, - .remove = acpi_fan_remove, - }, - .drv.pm =FAN_PM_OPS_PTR , +static struct platform_driver acpi_fan_driver = { + .probe = acpi_fan_probe, + .remove = acpi_fan_remove, + .driver = { + .name ="acpi-fan" , + .acpi_match_table = fan_device_ids, + .pm =FAN_PM_OPS_PTR , + }, };/* thermal cooling device callbacks */
@@ -126,17 +122,15 @@ static const struct thermal_cooling_device_ops fan_cooling_ops = {Driver Interface -------------------------------------------------------------------------- */ -static int acpi_fan_add (struct acpi_device *device) +static int acpi_fan_probe (struct platform_device *pdev) {int result =0 ;struct thermal_cooling_device *cdev; - -strcpy (acpi_device_name (device),"Fan" ); -strcpy (acpi_device_class (device),ACPI_FAN_CLASS ); +struct acpi_device *device =ACPI_COMPANION (&pdev->dev); result =acpi_device_update_power (device,NULL );if (result) { - printk(KERN_ERR PREFIX "Setting initial power state\n"); +dev_err (&pdev->dev,"Setting initial power state\n" ); goto end; }
@@ -147,24 +141,24 @@ static int acpi_fan_add(struct acpi_device *device) goto end; } -dev_dbg (&device->dev,"registered as cooling_device%d\n" , cdev->id); +dev_dbg (&pdev->dev,"registered as cooling_device%d\n" , cdev->id); - device->driver_data = cdev; - result =sysfs_create_link (&device->dev.kobj, +platform_set_drvdata (pdev, cdev); + result =sysfs_create_link (&pdev->dev.kobj, &cdev->device.kobj,"thermal_cooling" );if (result) -dev_err (&device->dev,"Failed to create sysfs link " +dev_err (&pdev->dev,"Failed to create sysfs link " "'thermal_cooling'\n" ); result =sysfs_create_link (&cdev->device.kobj, - &device->dev.kobj, + &pdev->dev.kobj,"device" );if (result) -dev_err (&device->dev,"Failed to create sysfs link " +dev_err (&pdev->dev,"Failed to create sysfs link " "'device'\n" ); - printk(KERN_INFO PREFIX "%s [%s] (%s)\n", +dev_info (&pdev->dev,"%s [%s] (%s)\n" ,acpi_device_name (device),acpi_device_bid (device), !device->power.state ?"on" :"off" );
@@ -172,11 +166,11 @@ static int acpi_fan_add(struct acpi_device *device)return result; } -static int acpi_fan_remove (struct acpi_device *device) +static int acpi_fan_remove (struct platform_device *pdev) { -struct thermal_cooling_device *cdev =acpi_driver_data (device); +struct thermal_cooling_device *cdev =platform_get_drvdata (pdev); -sysfs_remove_link (&device->dev.kobj,"thermal_cooling" ); +sysfs_remove_link (&pdev->dev.kobj,"thermal_cooling" );sysfs_remove_link (&cdev->device.kobj,"device" );thermal_cooling_device_unregister (cdev);
@@ -186,7 +180,7 @@ static int acpi_fan_remove(struct acpi_device *device)#ifdef CONFIG_PM_SLEEP static int acpi_fan_suspend (struct device *dev) { -acpi_device_set_power (to_acpi_device (dev),ACPI_STATE_D0 ); +acpi_device_set_power (ACPI_COMPANION (dev),ACPI_STATE_D0 );return AE_OK ; }
@@ -195,12 +189,12 @@ static int acpi_fan_resume(struct device *dev) {int result; - result =acpi_device_update_power (to_acpi_device (dev),NULL ); + result =acpi_device_update_power (ACPI_COMPANION (dev),NULL );if (result) - printk(KERN_ERR PREFIX "Error updating fan power state\n"); +dev_err (dev,"Error updating fan power state\n" );return result; }#endif -module_acpi_driver (acpi_fan_driver); +module_platform_driver (acpi_fan_driver);
Signature · 1 line
1.8.3.2
Zhang Rui
reviewerPATCH 11/19 ACPI / Fan: add ACPI 4.0 style fan support
In reply to Zhang RuiFrom: Aaron Lu <[email protected]>
This patch adds support for ACPI 4.0 style fan, lacking part is: no support for 'Low Speed Notification Support', 'Fine Grain Control' is not used yet.
It's not clear what to do on suspend/resume callback for 4.0 style ACPI fan, so it does nothing for now.
--- drivers/acpi/fan.c | 268 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 241 insertions(+), 27 deletions(-)
drivers/acpi/fan.c +241 -27
@@ -31,6 +31,7 @@#include <linux/thermal.h> #include <linux/acpi.h> #include <linux/platform_device.h> +#include <linux/sort.h> MODULE_AUTHOR ("Paul Diefenbaugh" );MODULE_DESCRIPTION ("ACPI Fan Driver" );
@@ -59,6 +60,29 @@ static struct dev_pm_ops acpi_fan_pm = {#define FAN_PM_OPS_PTR NULL#endif +struct acpi_fan_fps { +u64 control; +u64 trip_point; +u64 speed; +u64 noise_level; +u64 power; +}; + +struct acpi_fan_fif { +u64 revision; +u64 fine_grain_ctrl; +u64 step_size; +u64 low_speed_notification; +}; + +struct acpi_fan { +bool acpi4; +struct acpi_fan_fif fif; +struct acpi_fan_fps *fps; +int fps_count; +struct thermal_cooling_device *cdev; +}; +static struct platform_driver acpi_fan_driver = { .probe = acpi_fan_probe, .remove = acpi_fan_remove,
@@ -73,21 +97,62 @@ static struct platform_driver acpi_fan_driver = {static int fan_get_max_state (struct thermal_cooling_device *cdev,unsigned long *state) { -/* ACPI fan device only support two states: ON/OFF */ - *state =1 ; +struct acpi_device *device = cdev->devdata; +struct acpi_fan *fan =acpi_driver_data (device); + +if (fan->acpi4) + *state = fan->fps_count -1 ; +else + *state =1 ;return 0 ; } -static int fan_get_cur_state (struct thermal_cooling_device *cdev,unsigned long - *state) +static int fan_get_state_acpi4 (struct acpi_device *device,unsigned long *state) +{ +struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; +struct acpi_fan *fan =acpi_driver_data (device); +union acpi_object *obj; +acpi_status status; +int control, i; + + status =acpi_evaluate_object (device->handle,"_FST" ,NULL , &buffer); +if (ACPI_FAILURE (status)) { +dev_err (&device->dev,"Get fan state failed\n" ); +return status; + } + + obj = buffer.pointer; +if (!obj || obj->type !=ACPI_TYPE_PACKAGE || + obj->package.count !=3 || + obj->package.elements[1 ].type !=ACPI_TYPE_INTEGER ) { +dev_err (&device->dev,"Invalid _FST data\n" ); + status = -EINVAL ; + goto err; + } + + control = obj->package.elements[1 ].integer.value; +for (i =0 ; i < fan->fps_count; i++) { +if (control == fan->fps[i].control) +break ; + } +if (i == fan->fps_count) { +dev_dbg (&device->dev,"Invalid control value returned\n" ); + status = -EINVAL ; + goto err; + } + + *state = i; + +err: +kfree (obj); +return status; +} + +static int fan_get_state (struct acpi_device *device,unsigned long *state) { -struct acpi_device *device = cdev->devdata;int result;int acpi_state =ACPI_STATE_D0 ; -if (!device) -return -EINVAL ; - result =acpi_device_update_power (device, &acpi_state);if (result)return result;
@@ -97,21 +162,57 @@ static int fan_get_cur_state(struct thermal_cooling_device *cdev, unsigned longreturn 0 ; } -static int -fan_set_cur_state (struct thermal_cooling_device *cdev,unsigned long state) +static int fan_get_cur_state (struct thermal_cooling_device *cdev,unsigned long + *state) {struct acpi_device *device = cdev->devdata; -int result; +struct acpi_fan *fan =acpi_driver_data (device); + +if (fan->acpi4) +return fan_get_state_acpi4 (device, state); +else +return fan_get_state (device, state); +} -if (!device || (state !=0 && state !=1 )) +static int fan_set_state (struct acpi_device *device,unsigned long state) +{ +if (state !=0 && state !=1 )return -EINVAL ; - result =acpi_device_set_power (device, - state ?ACPI_STATE_D0 :ACPI_STATE_D3_COLD ); +return acpi_device_set_power (device, + state ?ACPI_STATE_D0 :ACPI_STATE_D3_COLD ); +} -return result; +static int fan_set_state_acpi4 (struct acpi_device *device,unsigned long state) +{ +struct acpi_fan *fan =acpi_driver_data (device); +acpi_status status; + +if (state >= fan->fps_count) +return -EINVAL ; + + status =acpi_execute_simple_method (device->handle,"_FSL" , + fan->fps[state].control); +if (ACPI_FAILURE (status)) { +dev_dbg (&device->dev,"Failed to set state by _FSL\n" ); +return status; + } + +return 0 ; } +static int +fan_set_cur_state (struct thermal_cooling_device *cdev,unsigned long state) +{ +struct acpi_device *device = cdev->devdata; +struct acpi_fan *fan =acpi_driver_data (device); + +if (fan->acpi4) +return fan_set_state_acpi4 (device, state); +else +return fan_set_state (device, state); + } +static const struct thermal_cooling_device_ops fan_cooling_ops = { .get_max_state = fan_get_max_state, .get_cur_state = fan_get_cur_state,
@@ -122,16 +223,125 @@ static const struct thermal_cooling_device_ops fan_cooling_ops = {Driver Interface -------------------------------------------------------------------------- */ +static bool acpi_fan_is_acpi4 (struct acpi_device *device) +{ +return acpi_has_method (device->handle,"_FIF" ) && +acpi_has_method (device->handle,"_FPS" ) && +acpi_has_method (device->handle,"_FSL" ) && +acpi_has_method (device->handle,"_FST" ); +} + +static int acpi_fan_get_fif (struct acpi_device *device) +{ +struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; +struct acpi_fan *fan =acpi_driver_data (device); +struct acpi_buffer format = {sizeof ("NNNN" ),"NNNN" }; +struct acpi_buffer fif = {sizeof (fan->fif), &fan->fif }; +union acpi_object *obj; +acpi_status status; + + status =acpi_evaluate_object (device->handle,"_FIF" ,NULL , &buffer); +if (ACPI_FAILURE (status)) +return status; + + obj = buffer.pointer; +if (!obj || obj->type !=ACPI_TYPE_PACKAGE ) { +dev_err (&device->dev,"Invalid _FIF data\n" ); + status = -EINVAL ; + goto err; + } + + status =acpi_extract_package (obj, &format, &fif); +if (ACPI_FAILURE (status)) { +dev_err (&device->dev,"Invalid _FIF element\n" ); + status = -EINVAL ; + } + +err: +kfree (obj); +return status; +} + +static int acpi_fan_speed_cmp (const void *a,const void *b) +{ +const struct acpi_fan_fps *fps1 = a; +const struct acpi_fan_fps *fps2 = b; +return fps1->speed - fps2->speed; +} + +static int acpi_fan_get_fps (struct acpi_device *device) +{ +struct acpi_fan *fan =acpi_driver_data (device); +struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; +union acpi_object *obj; +acpi_status status; +int i; + + status =acpi_evaluate_object (device->handle,"_FPS" ,NULL , &buffer); +if (ACPI_FAILURE (status)) +return status; + + obj = buffer.pointer; +if (!obj || obj->type !=ACPI_TYPE_PACKAGE || obj->package.count <2 ) { +dev_err (&device->dev,"Invalid _FPS data\n" ); + status = -EINVAL ; + goto err; + } + + fan->fps_count = obj->package.count -1 ;/* minus revision field */ + fan->fps =devm_kzalloc (&device->dev, + fan->fps_count *sizeof (struct acpi_fan_fps ), +GFP_KERNEL ); +if (!fan->fps) { +dev_err (&device->dev,"Not enough memory\n" ); + status = -ENOMEM ; + goto err; + } +for (i =0 ; i < fan->fps_count; i++) { +struct acpi_buffer format = {sizeof ("NNNNN" ),"NNNNN" }; +struct acpi_buffer fps = {sizeof (fan->fps[i]), &fan->fps[i] }; + status =acpi_extract_package (&obj->package.elements[i +1 ], + &format, &fps); +if (ACPI_FAILURE (status)) { +dev_err (&device->dev,"Invalid _FPS element\n" ); +break ; + } + } + +/* sort the state array according to fan speed in increase order */ +sort (fan->fps, fan->fps_count,sizeof (*fan->fps), + acpi_fan_speed_cmp,NULL ); + +err: +kfree (obj); +return status; +} +static int acpi_fan_probe (struct platform_device *pdev) {int result =0 ;struct thermal_cooling_device *cdev; +struct acpi_fan *fan;struct acpi_device *device =ACPI_COMPANION (&pdev->dev); - result =acpi_device_update_power (device,NULL ); -if (result) { -dev_err (&pdev->dev,"Setting initial power state\n" ); - goto end; + fan =devm_kzalloc (&pdev->dev,sizeof (*fan),GFP_KERNEL ); +if (!fan) { +dev_err (&device->dev,"No memory for fan\n" ); +return -ENOMEM ; + } + device->driver_data = fan; +platform_set_drvdata (pdev, fan); + +if (acpi_fan_is_acpi4 (device)) { +if (acpi_fan_get_fif (device) ||acpi_fan_get_fps (device)) + goto end; + fan->acpi4 = true; + }else { + result =acpi_device_update_power (device,NULL ); +if (result) { +dev_err (&device->dev,"Setting initial power state\n" ); + goto end; + } } cdev = thermal_cooling_device_register("Fan", device,
@@ -143,7 +353,7 @@ static int acpi_fan_probe(struct platform_device *pdev)dev_dbg (&pdev->dev,"registered as cooling_device%d\n" , cdev->id); -platform_set_drvdata (pdev, cdev); + fan->cdev = cdev; result =sysfs_create_link (&pdev->dev.kobj, &cdev->device.kobj,"thermal_cooling" );
@@ -158,21 +368,17 @@ static int acpi_fan_probe(struct platform_device *pdev)dev_err (&pdev->dev,"Failed to create sysfs link " "'device'\n" ); -dev_info (&pdev->dev,"%s [%s] (%s)\n" , -acpi_device_name (device),acpi_device_bid (device), - !device->power.state ?"on" :"off" ); - end:return result; }static int acpi_fan_remove (struct platform_device *pdev) { -struct thermal_cooling_device *cdev =platform_get_drvdata (pdev); +struct acpi_fan *fan =platform_get_drvdata (pdev);sysfs_remove_link (&pdev->dev.kobj,"thermal_cooling" ); -sysfs_remove_link (&cdev->device.kobj,"device" ); -thermal_cooling_device_unregister (cdev); +sysfs_remove_link (&fan->cdev->device.kobj,"device" ); +thermal_cooling_device_unregister (fan->cdev);return 0 ; }
@@ -180,6 +386,10 @@ static int acpi_fan_remove(struct platform_device *pdev)#ifdef CONFIG_PM_SLEEP static int acpi_fan_suspend (struct device *dev) { +struct acpi_fan *fan =dev_get_drvdata (dev); +if (fan->acpi4) +return 0 ; +acpi_device_set_power (ACPI_COMPANION (dev),ACPI_STATE_D0 );return AE_OK ;
@@ -188,6 +398,10 @@ static int acpi_fan_suspend(struct device *dev)static int acpi_fan_resume (struct device *dev) {int result; +struct acpi_fan *fan =dev_get_drvdata (dev); + +if (fan->acpi4) +return 0 ; result =acpi_device_update_power (ACPI_COMPANION (dev),NULL );if (result)
Signature · 1 line
1.8.3.2
Zhang Rui
reviewerPATCH 12/19 ACPI / Fan: support INT3404 thermal device
In reply to Zhang RuiFrom: Aaron Lu <[email protected]>
INT3404 ACPI object follows the ACPI 5.0 fan object definition as described in section 11.3 of the ACPI 5.0 Specification. Thus we can reuse the ACPI fan driver for INT3404 ACPI object.
--- drivers/acpi/fan.c | 1 + 1 file changed, 1 insertion(+)
drivers/acpi/fan.c +1 -0
@@ -42,6 +42,7 @@ static int acpi_fan_remove(struct platform_device *pdev);static const struct acpi_device_id fan_device_ids[] = { {"PNP0C0B" ,0 }, + {"INT3404" ,0 }, {"" ,0 }, };MODULE_DEVICE_TABLE (acpi, fan_device_ids);
Signature · 1 line
1.8.3.2
Zhang Rui
reviewerPATCH 13/19 Thermal: move the KELVIN_TO_MILLICELSIUS macro to thermal.h
In reply to Zhang RuiFrom: Aaron Lu <[email protected]>
This macro can be used by other component so move it to a common header, but in a slightly different way: define two macros, one macro with an offset and the other doesn't.
--- drivers/acpi/thermal.c | 18 +++++++++--------- include/linux/thermal.h | 2 ++ 2 files changed, 11 insertions(+), 9 deletions(-)
drivers/acpi/thermal.c +9 -9
@@ -528,7 +528,6 @@ static void acpi_thermal_check(void *data) }/* sys I/F for generic thermal sysfs support */ -#define KELVIN_TO_MILLICELSIUS (t, off) (((t) - (off)) * 100)static int thermal_get_temp (struct thermal_zone_device *thermal,unsigned long *temp)
@@ -543,7 +542,8 @@ static int thermal_get_temp(struct thermal_zone_device *thermal,if (result)return result; - *temp =KELVIN_TO_MILLICELSIUS (tz->temperature, tz->kelvin_offset); + *temp =DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET (tz->temperature, + tz->kelvin_offset);return 0 ; }
@@ -647,7 +647,7 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal,if (tz->trips.critical.flags.valid) {if (!trip) { - *temp =KELVIN_TO_MILLICELSIUS ( + *temp =DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET ( tz->trips.critical.temperature, tz->kelvin_offset);return 0 ;
@@ -657,7 +657,7 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal,if (tz->trips.hot.flags.valid) {if (!trip) { - *temp =KELVIN_TO_MILLICELSIUS ( + *temp =DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET ( tz->trips.hot.temperature, tz->kelvin_offset);return 0 ;
@@ -667,7 +667,7 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal,if (tz->trips.passive.flags.valid) {if (!trip) { - *temp =KELVIN_TO_MILLICELSIUS ( + *temp =DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET ( tz->trips.passive.temperature, tz->kelvin_offset);return 0 ;
@@ -678,7 +678,7 @@ static int thermal_get_trip_temp(struct thermal_zone_device *thermal,for (i =0 ; i <ACPI_THERMAL_MAX_ACTIVE && tz->trips.active[i].flags.valid; i++) {if (!trip) { - *temp =KELVIN_TO_MILLICELSIUS ( + *temp =DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET ( tz->trips.active[i].temperature, tz->kelvin_offset);return 0 ;
@@ -694,7 +694,7 @@ static int thermal_get_crit_temp(struct thermal_zone_device *thermal,struct acpi_thermal *tz = thermal->devdata;if (tz->trips.critical.flags.valid) { - *temperature =KELVIN_TO_MILLICELSIUS ( + *temperature =DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET ( tz->trips.critical.temperature, tz->kelvin_offset);return 0 ;
@@ -714,8 +714,8 @@ static int thermal_get_trend(struct thermal_zone_device *thermal,if (type ==THERMAL_TRIP_ACTIVE ) {unsigned long trip_temp; -unsigned long temp =KELVIN_TO_MILLICELSIUS (tz->temperature, - tz->kelvin_offset); +unsigned long temp =DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET ( + tz->temperature, tz->kelvin_offset);if (thermal_get_trip_temp (thermal, trip, &trip_temp))return -EINVAL ;
include/linux/thermal.h +2 -0
@@ -44,6 +44,8 @@#define KELVIN_TO_CELSIUS (t) (long)(((long)t-2732 >= 0) ? \ ((long)t-2732+5)/10 : ((long)t-2732-5)/10)#define CELSIUS_TO_KELVIN (t) ((t)*10+2732) +#define DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET (t, off) (((t) - (off)) * 100) +#define DECI_KELVIN_TO_MILLICELSIUS (t) DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET(t, 2732)/* Adding event notification support elements */ #define THERMAL_GENL_FAMILY_NAME "thermal_event"
Signature · 1 line
1.8.3.2
Zhang Rui
reviewerPATCH 14/19 Thermal: introduce INT3402 thermal driver
In reply to Zhang RuiFrom: Aaron Lu <[email protected]>
ACPI INT3402 device object could report temperature for the memory module. To expose such information to user space, a thermal zone device is registered for it so that the thermal sysfs interface can expose such information for userspace to use.
--- drivers/thermal/int340x_thermal/Makefile | 1 + drivers/thermal/int340x_thermal/int3402_thermal.c | 242 ++++++++++++++++++++++ include/linux/thermal.h | 2 + 3 files changed, 245 insertions(+) create mode 100644 drivers/thermal/int340x_thermal/int3402_thermal.c
drivers/thermal/int340x_thermal/Makefile +1 -0
@@ -1 +1,2 @@ obj-$(CONFIG_INT340X_THERMAL) += int3400_thermal.o +obj-$(CONFIG_INT340X_THERMAL) += int3402_thermal.o
drivers/thermal/int340x_thermal/int3402_thermal.c new file +242 -0
242 lines not on this page · raw message
include/linux/thermal.h +2 -0
@@ -46,6 +46,8 @@#define CELSIUS_TO_KELVIN (t) ((t)*10+2732)#define DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET (t, off) (((t) - (off)) * 100)#define DECI_KELVIN_TO_MILLICELSIUS (t) DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET(t, 2732) +#define MILLICELSIUS_TO_DECI_KELVIN_WITH_OFFSET (t, off) (((t) / 100) + (off)) +#define MILLICELSIUS_TO_DECI_KELVIN (t) MILLICELSIUS_TO_DECI_KELVIN_WITH_OFFSET(t, 2732)/* Adding event notification support elements */ #define THERMAL_GENL_FAMILY_NAME "thermal_event"
Signature · 1 line
1.8.3.2
Zhang Rui
reviewerPATCH 15/19 Thermal: introduce int3403 thermal driver
In reply to Zhang RuiFrom: Lan Tianyu <[email protected]>
ACPI INT3403 device object can be used to retrieve temperature date from temperature sensors present in the system, and to expose device' performance control.
The previous INT3403 thermal driver supports temperature reporting only, thus remove it and introduce this new & enhanced one.
--- drivers/thermal/Kconfig | 15 - drivers/thermal/Makefile | 1 - drivers/thermal/int3403_thermal.c | 296 ------------- drivers/thermal/int340x_thermal/Makefile | 1 + drivers/thermal/int340x_thermal/int3403_thermal.c | 489 ++++++++++++++++++++++ 5 files changed, 490 insertions(+), 312 deletions(-) delete mode 100644 drivers/thermal/int3403_thermal.c create mode 100644 drivers/thermal/int340x_thermal/int3403_thermal.c
drivers/thermal/Kconfig +0 -15
@@ -207,21 +207,6 @@ config X86_PKG_TEMP_THERMAL two trip points which can be set by user to get notifications via thermal notification methods. -config ACPI_INT3403_THERMAL - tristate "ACPI INT3403 thermal driver" - depends on X86 && ACPI - help - Newer laptops and tablets that use ACPI may have thermal sensors - outside the core CPU/SOC for thermal safety reasons. These - temperature sensors are also exposed for the OS to use via the so - called INT3403 ACPI object. This driver will, on devices that have - such sensors, expose the temperature information from these sensors - to userspace via the normal thermal framework. This means that a wide - range of applications and GUI widgets can show this information to - the user or use this information for making decisions. For example, - the Intel Thermal Daemon can use this information to allow the user - to select his laptop to run without turning on the fans. - config INTEL_SOC_DTS_THERMAL tristate "Intel SoCs DTS thermal driver" depends on X86 && IOSF_MBI
drivers/thermal/Makefile +0 -1
@@ -31,6 +31,5 @@ obj-$(CONFIG_INTEL_POWERCLAMP) += intel_powerclamp.o obj-$(CONFIG_X86_PKG_TEMP_THERMAL) += x86_pkg_temp_thermal.o obj-$(CONFIG_INTEL_SOC_DTS_THERMAL) += intel_soc_dts_thermal.o obj-$(CONFIG_TI_SOC_THERMAL) += ti-soc-thermal/ -obj-$(CONFIG_ACPI_INT3403_THERMAL) += int3403_thermal.o obj-$(CONFIG_INT340X_THERMAL) += int340x_thermal/ obj-$(CONFIG_ST_THERMAL) += st/
drivers/thermal/int3403_thermal.c deleted +0 -296
296 lines not on this page · raw message
drivers/thermal/int340x_thermal/Makefile +1 -0
@@ -1,2 +1,3 @@ obj-$(CONFIG_INT340X_THERMAL) += int3400_thermal.o obj-$(CONFIG_INT340X_THERMAL) += int3402_thermal.o +obj-$(CONFIG_INT340X_THERMAL) += int3403_thermal.o
drivers/thermal/int340x_thermal/int3403_thermal.c new file +489 -0
489 lines not on this page · raw message
Signature · 1 line
1.8.3.2
Zhang Rui
reviewerPATCH 16/19 Thermal: int340x_thermal: expose acpi thermal relationship tables
In reply to Zhang RuiFrom: Jacob Pan <[email protected]>
ACPI 4.0 introduced two thermal relationship tables via _ART (active cooling) and _TRT (passive cooling) objects. These tables contain many to many relationships among thermal sensors and cooling devices.
This patch parses _ART and _TRT and makes the result available to the userspace via an misc device interface. At the same time, kernel drivers can also request parsing results from internal kernel APIs.
The results include source and target devices, influence, and sampling rate in case of _TRT. For _ART, the result shows source device, target device, and weight percentage.
--- drivers/thermal/Kconfig | 5 + drivers/thermal/int340x_thermal/Makefile | 1 + drivers/thermal/int340x_thermal/acpi_thermal_rel.c | 400 +++++++++++++++++++++ drivers/thermal/int340x_thermal/acpi_thermal_rel.h | 84 +++++ 4 files changed, 490 insertions(+) create mode 100644 drivers/thermal/int340x_thermal/acpi_thermal_rel.c create mode 100644 drivers/thermal/int340x_thermal/acpi_thermal_rel.h
drivers/thermal/Kconfig +5 -0
@@ -223,6 +223,7 @@ config INT340X_THERMAL tristate "ACPI INT340X thermal drivers" depends on X86 && ACPI select THERMAL_GOV_USER_SPACE + select ACPI_THERMAL_REL help Newer laptops and tablets that use ACPI may have thermal sensors and other devices with thermal control capabilities outside the core
@@ -237,6 +238,10 @@ config INT340X_THERMAL information to allow the user to select his laptop to run without turning on the fans. +config ACPI_THERMAL_REL + tristate + depends on ACPI + menu "Texas Instruments thermal drivers" source "drivers/thermal/ti-soc-thermal/Kconfig" endmenu
drivers/thermal/int340x_thermal/Makefile +1 -0
@@ -1,3 +1,4 @@ obj-$(CONFIG_INT340X_THERMAL) += int3400_thermal.o obj-$(CONFIG_INT340X_THERMAL) += int3402_thermal.o obj-$(CONFIG_INT340X_THERMAL) += int3403_thermal.o +obj-$(CONFIG_ACPI_THERMAL_REL) += acpi_thermal_rel.o
drivers/thermal/int340x_thermal/acpi_thermal_rel.c new file +400 -0
400 lines not on this page · raw message
drivers/thermal/int340x_thermal/acpi_thermal_rel.h new file +84 -0
84 lines not on this page · raw message
Signature · 1 line
1.8.3.2
Zhang Rui
reviewerPATCH 17/19 Thermal: int3400_thermal: use acpi_thermal_rel parsing APIs
In reply to Zhang RuiFrom: Jacob Pan <[email protected]>
ACPI _TRT and _ART parsing code has been moved to acpi_thermal_rel such that it can be used by other devices in the future. Use the parsing APIs in acpi_thermal_rel.c instead.
--- drivers/thermal/int340x_thermal/int3400_thermal.c | 172 ++-------------------- 1 file changed, 13 insertions(+), 159 deletions(-)
drivers/thermal/int340x_thermal/int3400_thermal.c +13 -159
@@ -14,33 +14,7 @@#include <linux/platform_device.h> #include <linux/acpi.h> #include <linux/thermal.h> - -struct art { -acpi_handle source; -acpi_handle target; -u64 weight; -u64 ac0_max; -u64 ac1_max; -u64 ac2_max; -u64 ac3_max; -u64 ac4_max; -u64 ac5_max; -u64 ac6_max; -u64 ac7_max; -u64 ac8_max; -u64 ac9_max; -}; - -struct trt { -acpi_handle source; -acpi_handle target; -u64 influence; -u64 sampling_period; -u64 reverved1; -u64 reverved2; -u64 reverved3; -u64 reverved4; -}; +#include "acpi_thermal_rel.h" enum int3400_thermal_uuid {INT3400_THERMAL_PASSIVE_1 ,
@@ -68,6 +42,7 @@ struct int3400_thermal_priv {int trt_count;struct trt *trts;u8 uuid_bitmap; +int rel_misc_dev_res; };static int int3400_thermal_get_uuids (struct int3400_thermal_priv *priv)
@@ -146,136 +121,6 @@ static int int3400_thermal_run_osc(acpi_handle handle,return result; } - -static int parse_art (struct int3400_thermal_priv *priv) -{ -acpi_handle handle = priv->adev->handle; -acpi_status status; -int result =0 ; -int i; -struct acpi_device *adev; -union acpi_object *p; -struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; -struct acpi_buffer element = {0 ,NULL }; -struct acpi_buffer art_format = { -sizeof ("RRNNNNNNNNNNN" ),"RRNNNNNNNNNNN" }; - -if (!acpi_has_method (handle,"_ART" )) -return 0 ; - - status =acpi_evaluate_object (handle,"_ART" ,NULL , &buffer); -if (ACPI_FAILURE (status)) -return -ENODEV ; - - p = buffer.pointer; -if (!p || (p->type !=ACPI_TYPE_PACKAGE )) { -pr_err ("Invalid _ART data\n" ); - result = -EFAULT ; - goto end; - } - -/* ignore p->package.elements[0], as this is _ART Revision field */ - priv->art_count = p->package.count -1 ; - priv->arts =kzalloc (sizeof (struct art ) * priv->art_count,GFP_KERNEL ); -if (!priv->arts) { - result = -ENOMEM ; - goto end; - } - -for (i =0 ; i < priv->art_count; i++) { -struct art *art = &(priv->arts[i]); - - element.length =sizeof (struct art ); - element.pointer = art; - - status =acpi_extract_package (&(p->package.elements[i +1 ]), - &art_format, &element); -if (ACPI_FAILURE (status)) { -pr_err ("Invalid _ART data" ); - result = -EFAULT ; -kfree (priv->arts); - goto end; - } - result =acpi_bus_get_device (art->source, &adev); -if (!result) -acpi_create_platform_device (adev,NULL ); -else -pr_warn ("Failed to get source ACPI device\n" ); - result =acpi_bus_get_device (art->target, &adev); -if (!result) -acpi_create_platform_device (adev,NULL ); -else -pr_warn ("Failed to get source ACPI device\n" ); - } -end: -kfree (buffer.pointer); -return result; -} - -static int parse_trt (struct int3400_thermal_priv *priv) -{ -acpi_handle handle = priv->adev->handle; -acpi_status status; -int result =0 ; -int i; -struct acpi_device *adev; -union acpi_object *p; -struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; -struct acpi_buffer element = {0 ,NULL }; -struct acpi_buffer trt_format = {sizeof ("RRNNNNNN" ),"RRNNNNNN" }; - -if (!acpi_has_method (handle,"_TRT" )) -return 0 ; - - status =acpi_evaluate_object (handle,"_TRT" ,NULL , &buffer); -if (ACPI_FAILURE (status)) -return -ENODEV ; - - p = buffer.pointer; -if (!p || (p->type !=ACPI_TYPE_PACKAGE )) { -pr_err ("Invalid _TRT data\n" ); - result = -EFAULT ; - goto end; - } - - priv->trt_count = p->package.count; - priv->trts =kzalloc (sizeof (struct trt ) * priv->trt_count,GFP_KERNEL ); -if (!priv->trts) { - result = -ENOMEM ; - goto end; - } - -for (i =0 ; i < priv->trt_count; i++) { -struct trt *trt = &(priv->trts[i]); - - element.length =sizeof (struct trt ); - element.pointer = trt; - - status =acpi_extract_package (&(p->package.elements[i]), - &trt_format, &element); -if (ACPI_FAILURE (status)) { -pr_err ("Invalid _ART data" ); - result = -EFAULT ; -kfree (priv->trts); - goto end; - } - - result =acpi_bus_get_device (trt->source, &adev); -if (!result) -acpi_create_platform_device (adev,NULL ); -else -pr_warn ("Failed to get source ACPI device\n" ); - result =acpi_bus_get_device (trt->target, &adev); -if (!result) -acpi_create_platform_device (adev,NULL ); -else -pr_warn ("Failed to get target ACPI device\n" ); - } -end: -kfree (buffer.pointer); -return result; -} -static int int3400_thermal_get_temp (struct thermal_zone_device *thermal,unsigned long *temp) {
@@ -350,11 +195,14 @@ static int int3400_thermal_probe(struct platform_device *pdev)if (result) goto free_priv; - result =parse_art (priv); + result =acpi_parse_art (priv->adev->handle, &priv->art_count, + &priv->arts, true);if (result) goto free_priv; - result =parse_trt (priv); + + result =acpi_parse_trt (priv->adev->handle, &priv->trt_count, + &priv->trts, true);if (result) goto free_art;
@@ -372,6 +220,9 @@ static int int3400_thermal_probe(struct platform_device *pdev) goto free_trt; } + priv->rel_misc_dev_res =acpi_thermal_rel_misc_device_add ( + priv->adev->handle); +return 0 ; free_trt:kfree (priv->trts);
@@ -386,6 +237,9 @@ static int int3400_thermal_remove(struct platform_device *pdev) {struct int3400_thermal_priv *priv =platform_get_drvdata (pdev); +if (!priv->rel_misc_dev_res) +acpi_thermal_rel_misc_device_remove (priv->adev->handle); +thermal_zone_device_unregister (priv->thermal);kfree (priv->trts);kfree (priv->arts);
Signature · 1 line
1.8.3.2
Zhang Rui
reviewerPATCH 18/19 Thermal: introduce INT3406 thermal driver
In reply to Zhang RuiFrom: Aaron Lu <[email protected]>
INT3406 ACPI device object resembles an ACPI video output device, but its _BCM is said to be deprecated and should not be used. So we will make use of the raw interface to do the actual cooling. Due to this, the backlight core has some modifications. Also, to re-use some of the ACPI video module's code, one function has been exported.
--- drivers/acpi/video.c | 78 ++++---- drivers/thermal/int340x_thermal/Makefile | 1 + drivers/thermal/int340x_thermal/int3406_thermal.c | 230 ++++++++++++++++++++++ drivers/video/backlight/backlight.c | 44 +++-- include/acpi/video.h | 20 ++ include/linux/backlight.h | 2 + 6 files changed, 323 insertions(+), 52 deletions(-) create mode 100644 drivers/thermal/int340x_thermal/int3406_thermal.c
drivers/acpi/video.c +41 -37
@@ -186,19 +186,6 @@ struct acpi_video_device_cap { u8 _DDC:1; /* Return the EDID for this device */ }; -struct acpi_video_brightness_flags { -u8 _BCL_no_ac_battery_levels:1 ;/* no AC/Battery levels in _BCL */ -u8 _BCL_reversed:1 ;/* _BCL package is in a reversed order */ -u8 _BQC_use_index:1 ;/* _BQC returns an index value */ -}; - -struct acpi_video_device_brightness { -int curr; -int count; -int *levels; -struct acpi_video_brightness_flags flags; -}; -struct acpi_video_device {unsigned long device_id;struct acpi_video_device_flags flags;
@@ -344,7 +331,7 @@ static const struct thermal_cooling_device_ops video_cooling_ops = {*/ static int -acpi_video_device_lcd_query_levels (struct acpi_video_device *device, +acpi_video_device_lcd_query_levels (acpi_handle handle,union acpi_object **levels) {int status;
@@ -354,7 +341,7 @@ acpi_video_device_lcd_query_levels(struct acpi_video_device *device, *levels =NULL ; - status =acpi_evaluate_object (device->dev->handle,"_BCL" ,NULL , &buffer); + status =acpi_evaluate_object (handle,"_BCL" ,NULL , &buffer);if (!ACPI_SUCCESS (status))return status; obj = (union acpi_object *)buffer.pointer;
@@ -943,29 +930,18 @@ static int acpi_video_bqc_quirk(struct acpi_video_device *device,return 0 ; } - -/* -* Arg: -* device : video output device (LCD, CRT, ..) -* -* Return Value: -* Maximum brightness level -* -* Allocate and initialize device->brightness. -*/ - -static int -acpi_video_init_brightness (struct acpi_video_device *device) +int acpi_video_get_levels (struct acpi_device *device, +struct acpi_video_device_brightness **dev_br) {union acpi_object *obj =NULL ;int i, max_level =0 , count =0 , level_ac_battery =0 ; -unsigned long long level, level_old;union acpi_object *o;struct acpi_video_device_brightness *br =NULL ; -int result = -EINVAL ; +int result =0 ;u32 value; -if (!ACPI_SUCCESS (acpi_video_device_lcd_query_levels (device, &obj))) { +if (!ACPI_SUCCESS (acpi_video_device_lcd_query_levels (device->handle, + &obj))) {ACPI_DEBUG_PRINT ((ACPI_DB_INFO ,"Could not query available " "LCD brightness level\n" )); goto out;
@@ -1038,6 +1014,38 @@ acpi_video_init_brightness(struct acpi_video_device *device) "Found unordered _BCL package")); br->count = count; + *dev_br = br; + +out: +kfree (obj); +return result; +out_free: +kfree (br); + goto out; +} +EXPORT_SYMBOL (acpi_video_get_levels); + +/* +* Arg: +* device : video output device (LCD, CRT, ..) +* +* Return Value: +* Maximum brightness level +* +* Allocate and initialize device->brightness. +*/ + +static int +acpi_video_init_brightness (struct acpi_video_device *device) +{ +int i, max_level =0 ; +unsigned long long level, level_old; +struct acpi_video_device_brightness *br =NULL ; +int result = -EINVAL ; + + result =acpi_video_get_levels (device->dev, &br); +if (result) +return result; device->brightness = br;/* _BQC uses INDEX while _BCL uses VALUE in some laptops */
@@ -1080,17 +1088,13 @@ acpi_video_init_brightness(struct acpi_video_device *device) goto out_free_levels;ACPI_DEBUG_PRINT ((ACPI_DB_INFO , -"found %d brightness levels\n" , count -2 )); -kfree (obj); -return result; +"found %d brightness levels\n" , br->count -2 )); +return 0 ; out_free_levels:kfree (br->levels); -out_free:kfree (br); -out: device->brightness =NULL ; -kfree (obj);return result; }
drivers/thermal/int340x_thermal/Makefile +1 -0
@@ -1,4 +1,5 @@ obj-$(CONFIG_INT340X_THERMAL) += int3400_thermal.o obj-$(CONFIG_INT340X_THERMAL) += int3402_thermal.o obj-$(CONFIG_INT340X_THERMAL) += int3403_thermal.o +obj-$(CONFIG_INT340X_THERMAL) += int3406_thermal.o obj-$(CONFIG_ACPI_THERMAL_REL) += acpi_thermal_rel.o
drivers/thermal/int340x_thermal/int3406_thermal.c new file +230 -0
230 lines not on this page · raw message
drivers/video/backlight/backlight.c +29 -15
77 lines not on this page · raw message
include/acpi/video.h +20 -0
@@ -3,6 +3,19 @@#include <linux/errno.h> /* for ENODEV */ +struct acpi_video_brightness_flags { +u8 _BCL_no_ac_battery_levels:1 ;/* no AC/Battery levels in _BCL */ +u8 _BCL_reversed:1 ;/* _BCL package is in a reversed order */ +u8 _BQC_use_index:1 ;/* _BQC returns an index value */ +}; + +struct acpi_video_device_brightness { +int curr; +int count; +int *levels; +struct acpi_video_brightness_flags flags; +}; +struct acpi_device ;#define ACPI_VIDEO_CLASS "video"
@@ -22,6 +35,8 @@ extern void acpi_video_unregister(void);extern void acpi_video_unregister_backlight (void );extern int acpi_video_get_edid (struct acpi_device *device,int type,int device_id,void **edid); +extern int acpi_video_get_levels (struct acpi_device *device, +struct acpi_video_device_brightness **dev_br);extern bool acpi_video_verify_backlight_support (void );#else static inline int acpi_video_register (void ) {return 0 ; }
@@ -32,6 +47,11 @@ static inline int acpi_video_get_edid(struct acpi_device *device, int type, {return -ENODEV ; } +static int acpi_video_get_levels (struct acpi_device *device, +struct acpi_video_device_brightness **dev_br) +{ +return -ENODEV ; +}static inline bool acpi_video_verify_backlight_support (void ) {return false; }#endif
include/linux/backlight.h +2 -0
@@ -140,6 +140,8 @@ extern void backlight_force_update(struct backlight_device *bd,extern bool backlight_device_registered (enum backlight_type type);extern int backlight_register_notifier (struct notifier_block *nb);extern int backlight_unregister_notifier (struct notifier_block *nb); +extern struct backlight_device *backlight_device_get_by_type (enum backlight_type type); +extern int backlight_device_set_brightness (struct backlight_device *bd,int brightness);#define to_backlight_device (obj) container_of(obj, struct backlight_device, dev)
Signature · 1 line
1.8.3.2
Zhang Rui
reviewerPATCH 19/19 Thermal: int340x thermal: select ACPI fan driver
In reply to Zhang Ruiwe share the same driver for both ACPI predefined Fan device and INT3404 Fan device, thus we should select the ACPI Fan driver when int340x thermal drivers are enabeld.
--- drivers/acpi/Kconfig | 2 +- drivers/thermal/Kconfig | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/acpi/Kconfig +1 -1
@@ -144,7 +144,7 @@ config ACPI_VIDEO config ACPI_FAN tristate "Fan" - select THERMAL + depends on THERMAL default y help This driver supports ACPI fan devices, allowing user-mode
drivers/thermal/Kconfig +1 -0
@@ -224,6 +224,7 @@ config INT340X_THERMAL depends on X86 && ACPI select THERMAL_GOV_USER_SPACE select ACPI_THERMAL_REL + select ACPI_FAN help Newer laptops and tablets that use ACPI may have thermal sensors and other devices with thermal control capabilities outside the core
Signature · 1 line
1.8.3.2