hwmon: Add Baikal-T1 SoC Process, Voltage and Temp sensor support
Subsystems (4)
v4 cover hwmon: Add Baikal-T1 SoC Process, Voltage and Temp sensor support
In order to keep track of Baikal-T1 SoC power consumption and make sure the chip heating is within the normal temperature limits, there is a dedicated hardware monitor sensor embedded into the SoC. It is based on the Analog Bits PVT sensor but equipped with a vendor-specific control wrapper, which ease an access to the sensors functionality. Fist of all it provides an accessed to the sampled Temperature, Voltage and Low/Standard/High Voltage thresholds. In addition the wrapper generates an interrupt in case if one enabled for alarm thresholds or data ready event. All of these functionality is implemented in the Baikal-T1 PVT driver submitted within this patchset. Naturally there is also a patch, which creates a corresponding yaml-based dt-binding file for the sensor.
This patchset is rebased and tested on the mainline Linux kernel 5.6-rc4:
base-commit: 0e698dfa2822 ("Linux 5.7-rc4")
tag: v5.7-rc4
Note new vendor prefix for Baikal-T1 PVT device will be added in the framework of the next patchset:
https://lkml.org/lkml/2020/5/6/1047
Changelog v2:
- Don't use a multi-arg clock phandle reference in the examples dt-bindings property. Thus reundant include pre-processor statement can be removed.
- Rearrange the SoBs with adding Maxim' co-development tag.
- Lowercase the node-name in the dt-schema example.
- Add dual license header to the dt-bindings file.
- Replace "additionalProperties: false" property with "unevaluatedProperties: false".
- Discard label definition from the binding example.
- Discard handwritten IO-access wrappers. Use normal readl/writel instead.
- Use generic FIELD_{GET,PREP} macros instead of handwritten ones.
- Since the driver depends on the OF config we can remove of_match_ptr() macro utilization.
- Don't print error-message if no platform IRQ found. Just return an error.
- Remove probe-status info string printout.
- Our corporate email server doesn't change Message-Id anymore, so the patchset is resubmitted being in the cover-letter-threaded format.
Changelog v3:
- Add bt1-pvt into the Documentation/hwmon/index.rst file.
- Discard explicit "default n" from the SENSORS_BT1_PVT_ALARMS config.
- Use "depends on SENSORS_BT1_PVT" statement instead of if-endif kbuild config clause.
- Alphabetically order the include macro operators.
- Discard unneeded include macro in the header file.
- Use new generic interface of the hwmon alarms notifications introduced in the first patch (based on hwmon_notify_event()).
- Add more descriptive information regarding the temp1_trim attribute.
- Discard setting the platforms device private data by using platform_set_drvdata(). It's redundant since unused in the driver.
- Pass "pvt" hwmon name instead of dev_name(dev) to devm_hwmon_device_register_with_info().
- Add "baikal,pvt-temp-trim-millicelsius" temperature trim DT property support.
- Discard kernel log warnings printed from the ISR when either min or max threshold levels are crossed.
- Discard CONFIG_OF dependency since there is non at compile-time.
Changelog v4:
- Rename temp1_trim to the temp1_offset and use the standard API to expose the attribute.
- Rename "baikal,pvt-temp-trim-millicelsius" DT property to "baikal,pvt-temp-offset-millicelsius".
- Switch "const static" order to be "static const" where it's applicable.
- Add missing headers "linux/io.h" and "linux/of.h".
- Add static qualifier to the pvt_hwmon_write() method, which has been missed there by mistake.
Guenter Roeck (1):
hwmon: Add notification support
Serge Semin (2):
dt-bindings: hwmon: Add Baikal-T1 PVT sensor binding
hwmon: Add Baikal-T1 PVT sensor driver
.../bindings/hwmon/baikal,bt1-pvt.yaml | 107 ++ Documentation/hwmon/bt1-pvt.rst | 117 ++ Documentation/hwmon/index.rst | 1 + drivers/hwmon/Kconfig | 25 + drivers/hwmon/Makefile | 1 + drivers/hwmon/bt1-pvt.c | 1146 +++++++++++++++++ drivers/hwmon/bt1-pvt.h | 244 ++++ drivers/hwmon/hwmon.c | 69 +- include/linux/hwmon.h | 3 + 9 files changed, 1710 insertions(+), 3 deletions(-) create mode 100644 Documentation/devicetree/bindings/hwmon/baikal,bt1-pvt.yaml create mode 100644 Documentation/hwmon/bt1-pvt.rst create mode 100644 drivers/hwmon/bt1-pvt.c create mode 100644 drivers/hwmon/bt1-pvt.h
Signature · 1 line
2.26.2
PATCH v4 1/3 dt-bindings: hwmon: Add Baikal-T1 PVT sensor binding
Baikal-T1 SoC is equipped with an embedded process, voltage and temperature sensor to monitor the chip internal environment like temperature, supply voltage and transistors performance.
This bindings describes the external Baikal-T1 PVT control interfaces like MMIO registers space, interrupt request number and clocks source. These are then used by the corresponding hwmon device driver to implement the sysfs files-based access to the sensors functionality.
---
Changelog v2:
- Lowercase the node-name in the example.
- Add dual-license header.
- Don't use a multi-arg clock phandle reference in the examples dt-binding property. Thus reundant include pre-processor statement can be removed.
- Replace "additionalProperties: false" property with "unevaluatedProperties: false".
- Discard label definition from the example.
- Align settings of the "#thermal-sensor-cells" property with two spaces ahead of the property line start.
Changelog v3:
- Add "baikal,pvt-temp-trim-millicelsius" property support.
Changelog v4:
- Rename the "baikal,pvt-temp-trim-millicelsius" property to "baikal,pvt-temp-offset-millicelsius".
--- .../bindings/hwmon/baikal,bt1-pvt.yaml | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/baikal,bt1-pvt.yaml
Documentation/devicetree/bindings/hwmon/baikal,bt1-pvt.yaml new file +107 -0
@@ -0,0 +1,107 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) 2020 BAIKAL ELECTRONICS, JSC +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hwmon/baikal,bt1-pvt.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Baikal-T1 PVT Sensor + +maintainers: + - Serge Semin <[email protected]> + +description: | + Baikal-T1 SoC provides an embedded process, voltage and temperature + sensor to monitor an internal SoC environment (chip temperature, supply + voltage and process monitor) and on time detect critical situations, + which may cause the system instability and even damages. The IP-block + is based on the Analog Bits PVT sensor, but is equipped with a dedicated + control wrapper, which provides a MMIO registers-based access to the + sensor core functionality (APB3-bus based) and exposes an additional + functions like thresholds/data ready interrupts, its status and masks, + measurements timeout. Its internal structure is depicted on the next + diagram: + + Analog Bits core Bakal-T1 PVT control block + +--------------------+ +------------------------+ + | Temperature sensor |-+ +------| Sensors control | + |--------------------| |<---En---| |------------------------| + | Voltage sensor |-|<--Mode--| +--->| Sampled data | + |--------------------| |<--Trim--+ | |------------------------| + | Low-Vt sensor |-| | +--| Thresholds comparator | + |--------------------| |---Data----| | |------------------------| + | High-Vt sensor |-| | +->| Interrupts status | + |--------------------| |--Valid--+-+ | |------------------------| + | Standard-Vt sensor |-+ +---+--| Interrupts mask | + +--------------------+ |------------------------| + ^ | Interrupts timeout | + | +------------------------+ + | ^ ^ + Rclk-----+----------------------------------------+ | + APB3-------------------------------------------------+ + + This bindings describes the external Baikal-T1 PVT control interfaces + like MMIO registers space, interrupt request number and clocks source. + These are then used by the corresponding hwmon device driver to + implement the sysfs files-based access to the sensors functionality. + +properties: + compatible: + const: baikal,bt1-pvt + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + items: + - description: PVT reference clock + - description: APB3 interface clock + + clock-names: + items: + - const: ref + - const: pclk + + "#thermal-sensor-cells": + description: Baikal-T1 can be referenced as the CPU thermal-sensor + const: 0 + + baikal,pvt-temp-offset-millicelsius: + description: | + Temperature sensor trimming factor. It can be used to manually adjust the + temperature measurements within 7.130 degrees Celsius. + maxItems: 1 + items: + default: 0 + minimum: 0 + maximum: 7130 + +unevaluatedProperties: false + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + +examples: + - | + #include <dt-bindings/interrupt-controller/mips-gic.h> + + pvt@1f200000 { + compatible = "baikal,bt1-pvt"; + reg = <0x1f200000 0x1000>; + #thermal-sensor-cells = <0>; + + interrupts = <GIC_SHARED 31 IRQ_TYPE_LEVEL_HIGH>; + + baikal,pvt-temp-trim-millicelsius = <1000>; + + clocks = <&ccu_sys>, <&ccu_sys>; + clock-names = "ref", "pclk"; + }; +...
Signature · 1 line
2.26.2
PATCH v4 2/3 hwmon: Add notification support
In reply to Serge SeminFrom: Guenter Roeck <[email protected]>
For hwmon drivers using the hwmon_device_register_with_info() API, it is desirable to have a generic notification mechanism available. This mechanism can be used to notify userspace as well as the thermal subsystem if the driver experiences any events, such as warning or critical alarms.
Implement hwmon_notify_event() to provide this mechanism. The function generates a sysfs event and a udev event. If the device is registered with the thermal subsystem and the event is associated with a temperature sensor, also notify the thermal subsystem that a thermal event occurred.
---
Guenter: I have no plan to push this since there are currently no users (and thus no means to test the code). However, I want to make sure that the patch is available if/when needed.
Serge: There is a user now. It's Baikal-T1 PVT driver. So the patch can be merged in.
Changelog v2: Skipped
Changelog v3:
- Fix merge conflicts found in struct hwmon_thermal_data and in hwmon_thermal_add_sensors().
- Use hwmon_attr_base() to get the hwmon attribute base index.
- Use the base value to get the sysfs-attribute name. hwmon_thermal_notify() is supposed to be called with normal index.
--- drivers/hwmon/hwmon.c | 69 +++++++++++++++++++++++++++++++++++++++++-- include/linux/hwmon.h | 3 ++ 2 files changed, 69 insertions(+), 3 deletions(-)
drivers/hwmon/hwmon.c +66 -3
@@ -15,6 +15,7 @@#include <linux/gfp.h> #include <linux/hwmon.h> #include <linux/idr.h> +#include <linux/list.h> #include <linux/module.h> #include <linux/pci.h> #include <linux/slab.h>
@@ -31,7 +32,7 @@ struct hwmon_device {const char *name;struct device dev;const struct hwmon_chip_info *chip; - +struct list_head tzdata;struct attribute_group group;const struct attribute_group **groups; };
@@ -55,12 +56,12 @@ struct hwmon_device_attribute {/* * Thermal zone information -* In addition to the reference to the hwmon device, -* also provides the sensor index. */ struct hwmon_thermal_data { +struct list_head node;/* hwmon tzdata list entry */ struct device *dev;/* Reference to hwmon device */ int index;/* sensor index */ +struct thermal_zone_device *tzd;/* thermal zone device */ }; static ssize_t
@@ -156,10 +157,17 @@ static const struct thermal_zone_of_device_ops hwmon_thermal_ops = { .get_temp = hwmon_thermal_get_temp, }; +static void hwmon_thermal_remove_sensor (void *data) +{ +list_del (data); +} +static int hwmon_thermal_add_sensor (struct device *dev,int index) { +struct hwmon_device *hwdev =to_hwmon_device (dev);struct hwmon_thermal_data *tdata;struct thermal_zone_device *tzd; +int err; tdata =devm_kzalloc (dev,sizeof (*tdata),GFP_KERNEL );if (!tdata)
@@ -177,13 +185,37 @@ static int hwmon_thermal_add_sensor(struct device *dev, int index)if (IS_ERR (tzd) && (PTR_ERR (tzd) != -ENODEV ))return PTR_ERR (tzd); + err =devm_add_action (dev, hwmon_thermal_remove_sensor, &tdata->node); +if (err) +return err; + + tdata->tzd = tzd; +list_add (&tdata->node, &hwdev->tzdata); + return 0; } + +static void hwmon_thermal_notify (struct device *dev,int index) +{ +struct hwmon_device *hwdev =to_hwmon_device (dev); +struct hwmon_thermal_data *tzdata; + +list_for_each_entry (tzdata, &hwdev->tzdata, node) { +if (tzdata->index == index) { +thermal_zone_device_update (tzdata->tzd, +THERMAL_EVENT_UNSPECIFIED ); + } + } +} +#else static int hwmon_thermal_add_sensor (struct device *dev,int index) {return 0 ; } + +static void hwmon_thermal_notify (struct device *dev,int index) { } +#endif /* IS_REACHABLE(CONFIG_THERMAL) && ... */ static int hwmon_attr_base (enum hwmon_sensor_types type)
@@ -511,6 +543,35 @@ static const int __templates_size[] = { [hwmon_intrusion] = ARRAY_SIZE(hwmon_intrusion_attr_templates), }; +int hwmon_notify_event (struct device *dev,enum hwmon_sensor_types type, +u32 attr,int channel) +{ +char sattr[MAX_SYSFS_ATTR_NAME_LENGTH ]; +const char *const *templates; +const char *template; +int base; + +if (type >=ARRAY_SIZE (__templates)) +return -EINVAL ; +if (attr >= __templates_size[type]) +return -EINVAL ; + + templates = __templates[type]; + template = templates[attr]; + + base =hwmon_attr_base (type); + +scnprintf (sattr,MAX_SYSFS_ATTR_NAME_LENGTH , template, base + channel); +sysfs_notify (&dev->kobj,NULL , sattr); +kobject_uevent (&dev->kobj,KOBJ_CHANGE ); + +if (type == hwmon_temp) +hwmon_thermal_notify (dev, channel); + +return 0 ; +} +EXPORT_SYMBOL_GPL (hwmon_notify_event); +static int hwmon_num_channel_attrs (const struct hwmon_channel_info *info) {int i, n;
@@ -661,6 +722,8 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata,if (err) goto free_hwmon; +INIT_LIST_HEAD (&hwdev->tzdata); +if (dev && dev->of_node && chip && chip->ops->read && chip->info[0 ]->type == hwmon_chip && (chip->info[0 ]->config[0 ] &HWMON_C_REGISTER_TZ )) {
include/linux/hwmon.h +3 -0
@@ -436,6 +436,9 @@ devm_hwmon_device_register_with_info(struct device *dev,void hwmon_device_unregister (struct device *dev);void devm_hwmon_device_unregister (struct device *dev); +int hwmon_notify_event (struct device *dev,enum hwmon_sensor_types type, +u32 attr,int channel); +/** * hwmon_is_bad_char - Is the char invalid in a hwmon name * @ch: the char to be considered
Signature · 1 line
2.26.2
PATCH v4 3/3 hwmon: Add Baikal-T1 PVT sensor driver
In reply to Serge SeminBaikal-T1 SoC provides an embedded process, voltage and temperature sensor to monitor an internal SoC environment (chip temperature, supply voltage and process monitor) and on time detect critical situations, which may cause the system instability and even damages. The IP-block is based on the Analog Bits PVT sensor, but is equipped with a dedicated control wrapper, which provides a MMIO registers-based access to the sensor core functionality (APB3-bus based) and exposes an additional functions like thresholds/data ready interrupts, its status and masks, measurements timeout. All of these is used to create a hwmon driver being added to the kernel by this commit.
The driver implements support for the hardware monitoring capabilities of Baikal-T1 process, voltage and temperature sensors. PVT IP-core consists of one temperature and four voltage sensors, each of which is implemented as a dedicated hwmon channel config.
The driver can optionally provide the hwmon alarms for each sensor the PVT controller supports. The alarms functionality is made compile-time configurable due to the hardware interface implementation peculiarity, which is connected with an ability to convert data from only one sensor at a time. Additional limitation is that the controller performs the thresholds checking synchronously with the data conversion procedure. Due to these limitations in order to have the hwmon alarms automatically detected the driver code must switch from one sensor to another, read converted data and manually check the threshold status bits. Depending on the measurements timeout settings this design may cause additional burden on the system performance. By default if the alarms kernel config is disabled the data conversion is performed by the driver on demand when read operation is requested via corresponding _input-file.
---
Changelog v2:
- Discard handwritten IO-access wrappers. Use normal readl/writel instead.
- Use generic FIELD_{GET,PREP} macros instead of handwritten ones.
- Since the driver depends on the OF config we can remove of_match_ptr() macro utilization.
- Don't print error-message if no platform IRQ found. Just return an error.
- Remove probe-status info string printout.
Changelog v3:
- Add bt1-pvt into the Documentation/hwmon/index.rst file.
- Discard explicit "default n" from the SENSORS_BT1_PVT_ALARMS config.
- Use "depends on SENSORS_BT1_PVT" statement instead of if-endif kbuild config clause.
- Alphabetically order the include macro operators.
- Discard unneeded include macro in the header file.
- Use new generic interface of the hwmon alarms notifications introduced in the first patch (based on hwmon_notify_event()).
- Add more descriptive information regarding the temp1_trim attribute.
- Discard setting the platforms device private data by using platform_set_drvdata(). It's redundant since unused in the driver.
- Pass "pvt" hwmon name instead of dev_name(dev) to devm_hwmon_device_register_with_info().
- Add "baikal,pvt-temp-trim-millicelsius" temperature trim DT property support.
- Discard kernel log warnings printed from the ISR when either min or max threshold levels are crossed.
- Discard CONFIG_OF dependency since there is non at compile-time.
Changelog v4:
- Rename temp1_trim to the temp1_offset and use the standard API to expose the attribute.
- Rename "baikal,pvt-temp-trim-millicelsius" to "baikal,pvt-temp-offset-millicelsius".
- Switch "const static" order to be "static const" where it's applicable.
- Add missing headers "linux/io.h" and "linux/of.h".
- Add static qualifier to the pvt_hwmon_write() method, which has been missed there by mistake.
--- Documentation/hwmon/bt1-pvt.rst | 117 ++++ Documentation/hwmon/index.rst | 1 + drivers/hwmon/Kconfig | 25 + drivers/hwmon/Makefile | 1 + drivers/hwmon/bt1-pvt.c | 1146 +++++++++++++++++++++++++++++++ drivers/hwmon/bt1-pvt.h | 244 +++++++ 6 files changed, 1534 insertions(+) create mode 100644 Documentation/hwmon/bt1-pvt.rst create mode 100644 drivers/hwmon/bt1-pvt.c create mode 100644 drivers/hwmon/bt1-pvt.h
Documentation/hwmon/bt1-pvt.rst new file +117 -0
@@ -0,0 +1,117 @@ +.. SPDX-License-Identifier: GPL-2.0-only + +Kernel driver bt1-pvt +===================== + +Supported chips: + + * Baikal-T1 PVT sensor (in SoC) + + Prefix: 'bt1-pvt' + + Addresses scanned: - + + Datasheet: Provided by BAIKAL ELECTRONICS upon request and under NDA + +Authors: + Maxim Kaurkin <[email protected]> + Serge Semin <[email protected]> + +Description +----------- + +This driver implements support for the hardware monitoring capabilities of the +embedded into Baikal-T1 process, voltage and temperature sensors. PVT IP-core +consists of one temperature and four voltage sensors, which can be used to +monitor the chip internal environment like heating, supply voltage and +transistors performance. The driver can optionally provide the hwmon alarms +for each sensor the PVT controller supports. The alarms functionality is made +compile-time configurable due to the hardware interface implementation +peculiarity, which is connected with an ability to convert data from only one +sensor at a time. Additional limitation is that the controller performs the +thresholds checking synchronously with the data conversion procedure. Due to +these in order to have the hwmon alarms automatically detected the driver code +must switch from one sensor to another, read converted data and manually check +the threshold status bits. Depending on the measurements timeout settings +(update_interval sysfs node value) this design may cause additional burden on +the system performance. So in case if alarms are unnecessary in your system +design it's recommended to have them disabled to prevent the PVT IRQs being +periodically raised to get the data cache/alarms status up to date. By default +in alarm-less configuration the data conversion is performed by the driver +on demand when read operation is requested via corresponding _input-file. + +Temperature Monitoring +---------------------- + +Temperature is measured with 10-bit resolution and reported in millidegree +Celsius. The driver performs all the scaling by itself therefore reports true +temperatures that don't need any user-space adjustments. While the data +translation formulae isn't linear, which gives us non-linear discreteness, +it's close to one, but giving a bit better accuracy for higher temperatures. +The temperature input is mapped as follows (the last column indicates the input +ranges):: + + temp1: CPU embedded diode -48.38C - +147.438C + +In case if the alarms kernel config is enabled in the driver the temperature input +has associated min and max limits which trigger an alarm when crossed. + +Voltage Monitoring +------------------ + +The voltage inputs are also sampled with 10-bit resolution and reported in +millivolts. But in this case the data translation formulae is linear, which +provides a constant measurements discreteness. The data scaling is also +performed by the driver, so returning true millivolts. The voltage inputs are +mapped as follows (the last column indicates the input ranges):: + + in0: VDD (processor core) 0.62V - 1.168V + in1: Low-Vt (low voltage threshold) 0.62V - 1.168V + in2: High-Vt (high voltage threshold) 0.62V - 1.168V + in3: Standard-Vt (standard voltage threshold) 0.62V - 1.168V + +In case if the alarms config is enabled in the driver the voltage inputs +have associated min and max limits which trigger an alarm when crossed. + +Sysfs Attributes +---------------- + +Following is a list of all sysfs attributes that the driver provides, their +permissions and a short description: + +=============================== ======= ======================================= +Name Perm Description +=============================== ======= ======================================= +update_interval RW Measurements update interval per + sensor. +temp1_type RO Sensor type (always 1 as CPU embedded + diode). +temp1_label RO CPU Core Temperature sensor. +temp1_input RO Measured temperature in millidegree + Celsius. +temp1_min RW Low limit for temp input. +temp1_max RW High limit for temp input. +temp1_min_alarm RO Temperature input alarm. Returns 1 if + temperature input went below min limit, + 0 otherwise. +temp1_max_alarm RO Temperature input alarm. Returns 1 if + temperature input went above max limit, + 0 otherwise. +temp1_offset RW Temperature offset in millidegree + Celsius which is added to the + temperature reading by the chip. It can + be used to manually adjust the + temperature measurements within 7.130 + degrees Celsius. +in[0-3]_label RO CPU Voltage sensor (either core or + low/high/standard thresholds). +in[0-3]_input RO Measured voltage in millivolts. +in[0-3]_min RW Low limit for voltage input. +in[0-3]_max RW High limit for voltage input. +in[0-3]_min_alarm RO Voltage input alarm. Returns 1 if + voltage input went below min limit, + 0 otherwise. +in[0-3]_max_alarm RO Voltage input alarm. Returns 1 if + voltage input went above max limit, + 0 otherwise. +=============================== ======= =======================================
Documentation/hwmon/index.rst +1 -0
@@ -43,6 +43,7 @@ Hardware Monitoring Kernel Drivers asc7621 aspeed-pwm-tacho bel-pfe + bt1-pvt coretemp da9052 da9055
drivers/hwmon/Kconfig +25 -0
@@ -404,6 +404,31 @@ config SENSORS_ATXP1 This driver can also be built as a module. If so, the module will be called atxp1. +config SENSORS_BT1_PVT + tristate "Baikal-T1 Process, Voltage, Temperature sensor driver" + depends on MIPS_BAIKAL_T1 || COMPILE_TEST + help + If you say yes here you get support for Baikal-T1 PVT sensor + embedded into the SoC. + + This driver can also be built as a module. If so, the module will be + called bt1-pvt. + +config SENSORS_BT1_PVT_ALARMS + bool "Enable Baikal-T1 PVT sensor alarms" + depends on SENSORS_BT1_PVT + help + Baikal-T1 PVT IP-block provides threshold registers for each + supported sensor. But the corresponding interrupts might be + generated by the thresholds comparator only in synchronization with + a data conversion. Additionally there is only one sensor data can + be converted at a time. All of these makes the interface impossible + to be used for the hwmon alarms implementation without periodic + switch between the PVT sensors. By default the data conversion is + performed on demand from the user-space. If this config is enabled + the data conversion will be periodically performed and the data will be + saved in the internal driver cache. + config SENSORS_DRIVETEMP tristate "Hard disk drives with temperature sensors" depends on SCSI && ATA
drivers/hwmon/Makefile +1 -0
@@ -53,6 +53,7 @@ obj-$(CONFIG_SENSORS_ASC7621) += asc7621.o obj-$(CONFIG_SENSORS_ASPEED) += aspeed-pwm-tacho.o obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o obj-$(CONFIG_SENSORS_AXI_FAN_CONTROL) += axi-fan-control.o +obj-$(CONFIG_SENSORS_BT1_PVT) += bt1-pvt.o obj-$(CONFIG_SENSORS_CORETEMP) += coretemp.o obj-$(CONFIG_SENSORS_DA9052_ADC)+= da9052-hwmon.o obj-$(CONFIG_SENSORS_DA9055)+= da9055-hwmon.o
drivers/hwmon/bt1-pvt.c new file +1146 -0
1,146 lines not on this page · raw message
drivers/hwmon/bt1-pvt.h new file +244 -0
244 lines not on this page · raw message
Signature · 1 line
2.26.2
kbuild test robot
build botRe: [PATCH v4 3/3] hwmon: Add Baikal-T1 PVT sensor driver
I love your patch! Perhaps something to improve:
Hi Serge,
I love your patch! Perhaps something to improve:
[auto build test WARNING on v5.7-rc7]
[cannot apply to hwmon/hwmon-next next-20200529]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Serge-Semin/hwmon-Add-Baikal-T1-SoC-Process-Voltage-and-Temp-sensor-support/20200528-223045 base: 9cb1fd0efd195590b828b9b865421ad345a4a145 config: i386-randconfig-a011-20200601 (attached as .config) compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 2388a096e7865c043e83ece4e26654bd3d1a20d5)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install i386 cross compiling tool for clang build
# apt-get install binutils-i386-linux-gnu
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=i386
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>, old ones prefixed by <<):
>> drivers/hwmon/bt1-pvt.c:67:30: warning: unused variable 'poly_temp_to_N' [-Wunused-const-variable]
static const struct pvt_poly poly_temp_to_N = {
^
>> drivers/hwmon/bt1-pvt.c:99:30: warning: unused variable 'poly_volt_to_N' [-Wunused-const-variable]static const struct pvt_poly poly_volt_to_N = {
^
2 warnings generated.
vim +/poly_temp_to_N +67 drivers/hwmon/bt1-pvt.c
46
47 /*
48 * The original translation formulae of the temperature (in degrees of Celsius)
49 * to PVT data and vice-versa are following:
50 * N = 1.8322e-8*(T^4) + 2.343e-5*(T^3) + 8.7018e-3*(T^2) + 3.9269*(T^1) +
51 * 1.7204e2,
52 * T = -1.6743e-11*(N^4) + 8.1542e-8*(N^3) + -1.8201e-4*(N^2) +
53 * 3.1020e-1*(N^1) - 4.838e1,
54 * where T = [-48.380, 147.438]C and N = [0, 1023].
55 * They must be accordingly altered to be suitable for the integer arithmetics.
56 * The technique is called 'factor redistribution', which just makes sure the
57 * multiplications and divisions are made so to have a result of the operations
58 * within the integer numbers limit. In addition we need to translate the
59 * formulae to accept millidegrees of Celsius. Here what they look like after
60 * the alterations:
61 * N = (18322e-20*(T^4) + 2343e-13*(T^3) + 87018e-9*(T^2) + 39269e-3*T +
62 * 17204e2) / 1e4,
63 * T = -16743e-12*(D^4) + 81542e-9*(D^3) - 182010e-6*(D^2) + 310200e-3*D -
64 * 48380,
65 * where T = [-48380, 147438] mC and N = [0, 1023].
66 */
> 67 static const struct pvt_poly poly_temp_to_N = {
68 .total_divider = 10000,
69 .terms = {
70 {4, 18322, 10000, 10000},
71 {3, 2343, 10000, 10},
72 {2, 87018, 10000, 10},
73 {1, 39269, 1000, 1},
74 {0, 1720400, 1, 1}
75 }
76 };
77
78 static const struct pvt_poly poly_N_to_temp = {
79 .total_divider = 1,
80 .terms = {
81 {4, -16743, 1000, 1},
82 {3, 81542, 1000, 1},
83 {2, -182010, 1000, 1},
84 {1, 310200, 1000, 1},
85 {0, -48380, 1, 1}
86 }
87 };
88
89 /*
90 * Similar alterations are performed for the voltage conversion equations.
91 * The original formulae are:
92 * N = 1.8658e3*V - 1.1572e3,
93 * V = (N + 1.1572e3) / 1.8658e3,
94 * where V = [0.620, 1.168] V and N = [0, 1023].
95 * After the optimization they looks as follows:
96 * N = (18658e-3*V - 11572) / 10,
97 * V = N * 10^5 / 18658 + 11572 * 10^4 / 18658.
98 */
> 99 static const struct pvt_poly poly_volt_to_N = { 100 .total_divider = 10,
101 .terms = {
102 {1, 18658, 1000, 1},
103 {0, -11572, 1, 1}
104 }
105 };
106
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Guenter Roeck
maintainerQuoted 12 lines · Serge Semin
In order to keep track of Baikal-T1 SoC power consumption and make sure the chip heating is within the normal temperature limits, there is a dedicated hardware monitor sensor embedded into the SoC. It is based on the Analog Bits PVT sensor but equipped with a vendor-specific control wrapper, which ease an access to the sensors functionality. Fist of all it provides an accessed to the sampled Temperature, Voltage and Low/Standard/High Voltage thresholds. In addition the wrapper generates an interrupt in case if one enabled for alarm thresholds or data ready event. All of these functionality is implemented in the Baikal-T1 PVT driver submitted within this patchset. Naturally there is also a patch, which creates a corresponding yaml-based dt-binding file for the sensor.
Quoted 4 lines
This patchset is rebased and tested on the mainline Linux kernel 5.6-rc4:
base-commit:0e698dfa2822("Linux 5.7-rc4")
tag: v5.7-rc4
Series applied to hwmon-next.
Thanks,
Guenter
Quoted 96 lines
Note new vendor prefix for Baikal-T1 PVT device will be added in the framework of the next patchset:
https://lkml.org/lkml/2020/5/6/1047Changelog v2:
- Don't use a multi-arg clock phandle reference in the examples dt-bindings property. Thus reundant include pre-processor statement can be removed.
- Rearrange the SoBs with adding Maxim' co-development tag.
- Lowercase the node-name in the dt-schema example.
- Add dual license header to the dt-bindings file.
- Replace "additionalProperties: false" property with "unevaluatedProperties: false".
- Discard label definition from the binding example.
- Discard handwritten IO-access wrappers. Use normal readl/writel instead.
- Use generic FIELD_{GET,PREP} macros instead of handwritten ones.
- Since the driver depends on the OF config we can removeof_match_ptr()macro utilization.
- Don't print error-message if no platform IRQ found. Just return an error.
- Remove probe-status info string printout.
- Our corporate email server doesn't change Message-Id anymore, so the patchset is resubmitted being in the cover-letter-threaded format.Changelog v3:
- Add bt1-pvt into theDocumentation/hwmon/index.rstfile.
- Discard explicit "default n" from theSENSORS_BT1_PVT_ALARMSconfig.
- Use "depends onSENSORS_BT1_PVT" statement instead of if-endif kbuild config clause.
- Alphabetically order the include macro operators.
- Discard unneeded include macro in the header file.
- Use new generic interface of the hwmon alarms notifications introduced in the first patch (based onhwmon_notify_event()).
- Add more descriptive information regarding thetemp1_trimattribute.
- Discard setting the platforms device private data by usingplatform_set_drvdata(). It's redundant since unused in the driver.
- Pass "pvt" hwmon name instead ofdev_name(dev)todevm_hwmon_device_register_with_info().
- Add "baikal,pvt-temp-trim-millicelsius" temperature trim DT property support.
- Discard kernel log warnings printed from the ISR when either min or max threshold levels are crossed.
- DiscardCONFIG_OFdependency since there is non at compile-time.Changelog v4:
- Renametemp1_trimto thetemp1_offsetand use the standard API to expose the attribute.
- Rename "baikal,pvt-temp-trim-millicelsius" DT property to "baikal,pvt-temp-offset-millicelsius".
- Switch "const static" order to be "static const" where it's applicable.
- Add missing headers "linux/io.h" and "linux/of.h".
- Add static qualifier to thepvt_hwmon_write()method, which has been missed there by mistake.Co-developed-by Maxim Kaurkin <[email protected]>Signed-off-by Maxim Kaurkin <[email protected]>Signed-off-by Serge Semin <[email protected]>Cc Alexey Malahov <[email protected]>Cc Pavel Parkhomenko <[email protected]>Cc Ramil Zaripov <[email protected]>Cc Ekaterina Skachko <[email protected]>Cc Vadim Vlasov <[email protected]>Cc Alexey Kolotnikov <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Rob Herring <[email protected]>Guenter Roeck (1):
hwmon: Add notification supportSerge Semin (2):
dt-bindings: hwmon: Add Baikal-T1 PVT sensor binding
hwmon: Add Baikal-T1 PVT sensor driver.../bindings/hwmon/baikal,bt1-pvt.yaml | 107 ++ Documentation/hwmon/bt1-pvt.rst | 117 ++ Documentation/hwmon/index.rst | 1 + drivers/hwmon/Kconfig | 25 + drivers/hwmon/Makefile | 1 + drivers/hwmon/bt1-pvt.c | 1146 +++++++++++++++++ drivers/hwmon/bt1-pvt.h | 244 ++++ drivers/hwmon/hwmon.c | 69 +- include/linux/hwmon.h | 3 + 9 files changed, 1710 insertions(+), 3 deletions(-) create mode 100644 Documentation/devicetree/bindings/hwmon/baikal,bt1-pvt.yaml create mode 100644 Documentation/hwmon/bt1-pvt.rst create mode 100644 drivers/hwmon/bt1-pvt.c create mode 100644 drivers/hwmon/bt1-pvt.hSignature · 1 line
2.26.2