Skip to content

Commit 87976ce

Browse files
fancergroeck
authored andcommitted
hwmon: Add Baikal-T1 PVT sensor driver
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. 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. 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: Thomas Bogendoerfer <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Rob Herring <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Guenter Roeck <[email protected]>
1 parent 1597b37 commit 87976ce

File tree

6 files changed

+1534
-0
lines changed

6 files changed

+1534
-0
lines changed

Documentation/hwmon/bt1-pvt.rst

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
.. SPDX-License-Identifier: GPL-2.0-only
2+
3+
Kernel driver bt1-pvt
4+
=====================
5+
6+
Supported chips:
7+
8+
* Baikal-T1 PVT sensor (in SoC)
9+
10+
Prefix: 'bt1-pvt'
11+
12+
Addresses scanned: -
13+
14+
Datasheet: Provided by BAIKAL ELECTRONICS upon request and under NDA
15+
16+
Authors:
17+
Maxim Kaurkin <[email protected]>
18+
Serge Semin <[email protected]>
19+
20+
Description
21+
-----------
22+
23+
This driver implements support for the hardware monitoring capabilities of the
24+
embedded into Baikal-T1 process, voltage and temperature sensors. PVT IP-core
25+
consists of one temperature and four voltage sensors, which can be used to
26+
monitor the chip internal environment like heating, supply voltage and
27+
transistors performance. The driver can optionally provide the hwmon alarms
28+
for each sensor the PVT controller supports. The alarms functionality is made
29+
compile-time configurable due to the hardware interface implementation
30+
peculiarity, which is connected with an ability to convert data from only one
31+
sensor at a time. Additional limitation is that the controller performs the
32+
thresholds checking synchronously with the data conversion procedure. Due to
33+
these in order to have the hwmon alarms automatically detected the driver code
34+
must switch from one sensor to another, read converted data and manually check
35+
the threshold status bits. Depending on the measurements timeout settings
36+
(update_interval sysfs node value) this design may cause additional burden on
37+
the system performance. So in case if alarms are unnecessary in your system
38+
design it's recommended to have them disabled to prevent the PVT IRQs being
39+
periodically raised to get the data cache/alarms status up to date. By default
40+
in alarm-less configuration the data conversion is performed by the driver
41+
on demand when read operation is requested via corresponding _input-file.
42+
43+
Temperature Monitoring
44+
----------------------
45+
46+
Temperature is measured with 10-bit resolution and reported in millidegree
47+
Celsius. The driver performs all the scaling by itself therefore reports true
48+
temperatures that don't need any user-space adjustments. While the data
49+
translation formulae isn't linear, which gives us non-linear discreteness,
50+
it's close to one, but giving a bit better accuracy for higher temperatures.
51+
The temperature input is mapped as follows (the last column indicates the input
52+
ranges)::
53+
54+
temp1: CPU embedded diode -48.38C - +147.438C
55+
56+
In case if the alarms kernel config is enabled in the driver the temperature input
57+
has associated min and max limits which trigger an alarm when crossed.
58+
59+
Voltage Monitoring
60+
------------------
61+
62+
The voltage inputs are also sampled with 10-bit resolution and reported in
63+
millivolts. But in this case the data translation formulae is linear, which
64+
provides a constant measurements discreteness. The data scaling is also
65+
performed by the driver, so returning true millivolts. The voltage inputs are
66+
mapped as follows (the last column indicates the input ranges)::
67+
68+
in0: VDD (processor core) 0.62V - 1.168V
69+
in1: Low-Vt (low voltage threshold) 0.62V - 1.168V
70+
in2: High-Vt (high voltage threshold) 0.62V - 1.168V
71+
in3: Standard-Vt (standard voltage threshold) 0.62V - 1.168V
72+
73+
In case if the alarms config is enabled in the driver the voltage inputs
74+
have associated min and max limits which trigger an alarm when crossed.
75+
76+
Sysfs Attributes
77+
----------------
78+
79+
Following is a list of all sysfs attributes that the driver provides, their
80+
permissions and a short description:
81+
82+
=============================== ======= =======================================
83+
Name Perm Description
84+
=============================== ======= =======================================
85+
update_interval RW Measurements update interval per
86+
sensor.
87+
temp1_type RO Sensor type (always 1 as CPU embedded
88+
diode).
89+
temp1_label RO CPU Core Temperature sensor.
90+
temp1_input RO Measured temperature in millidegree
91+
Celsius.
92+
temp1_min RW Low limit for temp input.
93+
temp1_max RW High limit for temp input.
94+
temp1_min_alarm RO Temperature input alarm. Returns 1 if
95+
temperature input went below min limit,
96+
0 otherwise.
97+
temp1_max_alarm RO Temperature input alarm. Returns 1 if
98+
temperature input went above max limit,
99+
0 otherwise.
100+
temp1_offset RW Temperature offset in millidegree
101+
Celsius which is added to the
102+
temperature reading by the chip. It can
103+
be used to manually adjust the
104+
temperature measurements within 7.130
105+
degrees Celsius.
106+
in[0-3]_label RO CPU Voltage sensor (either core or
107+
low/high/standard thresholds).
108+
in[0-3]_input RO Measured voltage in millivolts.
109+
in[0-3]_min RW Low limit for voltage input.
110+
in[0-3]_max RW High limit for voltage input.
111+
in[0-3]_min_alarm RO Voltage input alarm. Returns 1 if
112+
voltage input went below min limit,
113+
0 otherwise.
114+
in[0-3]_max_alarm RO Voltage input alarm. Returns 1 if
115+
voltage input went above max limit,
116+
0 otherwise.
117+
=============================== ======= =======================================

Documentation/hwmon/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Hardware Monitoring Kernel Drivers
4444
asc7621
4545
aspeed-pwm-tacho
4646
bel-pfe
47+
bt1-pvt
4748
coretemp
4849
da9052
4950
da9055

drivers/hwmon/Kconfig

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,31 @@ config SENSORS_ATXP1
414414
This driver can also be built as a module. If so, the module
415415
will be called atxp1.
416416

417+
config SENSORS_BT1_PVT
418+
tristate "Baikal-T1 Process, Voltage, Temperature sensor driver"
419+
depends on MIPS_BAIKAL_T1 || COMPILE_TEST
420+
help
421+
If you say yes here you get support for Baikal-T1 PVT sensor
422+
embedded into the SoC.
423+
424+
This driver can also be built as a module. If so, the module will be
425+
called bt1-pvt.
426+
427+
config SENSORS_BT1_PVT_ALARMS
428+
bool "Enable Baikal-T1 PVT sensor alarms"
429+
depends on SENSORS_BT1_PVT
430+
help
431+
Baikal-T1 PVT IP-block provides threshold registers for each
432+
supported sensor. But the corresponding interrupts might be
433+
generated by the thresholds comparator only in synchronization with
434+
a data conversion. Additionally there is only one sensor data can
435+
be converted at a time. All of these makes the interface impossible
436+
to be used for the hwmon alarms implementation without periodic
437+
switch between the PVT sensors. By default the data conversion is
438+
performed on demand from the user-space. If this config is enabled
439+
the data conversion will be periodically performed and the data will be
440+
saved in the internal driver cache.
441+
417442
config SENSORS_DRIVETEMP
418443
tristate "Hard disk drives with temperature sensors"
419444
depends on SCSI && ATA

drivers/hwmon/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ obj-$(CONFIG_SENSORS_ASC7621) += asc7621.o
5454
obj-$(CONFIG_SENSORS_ASPEED) += aspeed-pwm-tacho.o
5555
obj-$(CONFIG_SENSORS_ATXP1) += atxp1.o
5656
obj-$(CONFIG_SENSORS_AXI_FAN_CONTROL) += axi-fan-control.o
57+
obj-$(CONFIG_SENSORS_BT1_PVT) += bt1-pvt.o
5758
obj-$(CONFIG_SENSORS_CORETEMP) += coretemp.o
5859
obj-$(CONFIG_SENSORS_DA9052_ADC)+= da9052-hwmon.o
5960
obj-$(CONFIG_SENSORS_DA9055)+= da9055-hwmon.o

0 commit comments

Comments
 (0)