Commit 129b9a5c authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull hwmon updates from Guenter Roeck:
 "Infrastructure:
   - Add notification support

  New drivers:
   - Baikal-T1 PVT sensor driver
   - amd_energy driver to report energy counters
   - Driver for Maxim MAX16601
   - Gateworks System Controller

  Various:
   - applesmc: avoid overlong udelay()
   - dell-smm: Use one DMI match for all XPS models
   - ina2xx: Implement alert functions
   - lm70: Add support for ACPI
   - lm75: Fix coding-style warnings
   - lm90: Add max6654 support to lm90 driver
   - nct7802: Replace container_of() API
   - nct7904: Set default timeout
   - nct7904: Add watchdog function
   - pmbus: Improve initialization of 'currpage' and 'currphase'"

* tag 'hwmon-for-v5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: (24 commits)
  hwmon: Add Baikal-T1 PVT sensor driver
  hwmon: Add notification support
  dt-bindings: hwmon: Add Baikal-T1 PVT sensor binding
  hwmon: (applesmc) avoid overlong udelay()
  hwmon: (nct7904) Set default timeout
  hwmon: (amd_energy) Missing platform_driver_unregister() on error in amd_energy_init()
  MAINTAINERS: add entry for AMD energy driver
  hwmon: (amd_energy) Add documentation
  hwmon: Add amd_energy driver to report energy counters
  hwmon: (nct7802) Replace container_of() API
  hwmon: (lm90) Add max6654 support to lm90 driver
  hwmon : (nct6775) Use kobj_to_dev() API
  hwmon: (pmbus) Driver for Maxim MAX16601
  hwmon: (pmbus) Improve initialization of 'currpage' and 'currphase'
  hwmon: (adt7411) update contact email
  hwmon: (lm75) Fix all coding-style warnings on lm75 driver
  hwmon: Reduce indentation level in __hwmon_device_register()
  hwmon: (ina2xx) Implement alert functions
  hwmon: (lm70) Add support for ACPI
  hwmon: (dell-smm) Use one DMI match for all XPS models
  ...
parents b6f91ab6 87976ce2
Loading
Loading
Loading
Loading
+107 −0
Original line number Diff line number Diff line
# 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 <fancer.lancer@gmail.com>

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";
    };
...
+196 −0
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
%YAML 1.2
---
$id: http://devicetree.org/schemas/mfd/gateworks-gsc.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Gateworks System Controller

description: |
  The Gateworks System Controller (GSC) is a device present across various
  Gateworks product families that provides a set of system related features
  such as the following (refer to the board hardware user manuals to see what
  features are present)
   - Watchdog Timer
   - GPIO
   - Pushbutton controller
   - Hardware monitor with ADC's for temperature and voltage rails and
     fan controller

maintainers:
  - Tim Harvey <tharvey@gateworks.com>
  - Robert Jones <rjones@gateworks.com>

properties:
  $nodename:
    pattern: "gsc@[0-9a-f]{1,2}"
  compatible:
    const: gw,gsc

  reg:
    description: I2C device address
    maxItems: 1

  interrupts:
    maxItems: 1

  interrupt-controller: true

  "#interrupt-cells":
    const: 1

  "#address-cells":
    const: 1

  "#size-cells":
    const: 0

  adc:
    type: object
    description: Optional hardware monitoring module

    properties:
      compatible:
        const: gw,gsc-adc

      "#address-cells":
        const: 1

      "#size-cells":
        const: 0

    patternProperties:
      "^channel@[0-9]+$":
        type: object
        description: |
          Properties for a single ADC which can report cooked values
          (i.e. temperature sensor based on thermister), raw values
          (i.e. voltage rail with a pre-scaling resistor divider).

        properties:
          reg:
            description: Register of the ADC
            maxItems: 1

          label:
            description: Name of the ADC input

          gw,mode:
            description: |
              conversion mode:
                0 - temperature, in C*10
                1 - pre-scaled voltage value
                2 - scaled voltage based on an optional resistor divider
                    and optional offset
            $ref: /schemas/types.yaml#/definitions/uint32
            enum: [0, 1, 2]

          gw,voltage-divider-ohms:
            description: Values of resistors for divider on raw ADC input
            maxItems: 2
            items:
             minimum: 1000
             maximum: 1000000

          gw,voltage-offset-microvolt:
            description: |
              A positive voltage offset to apply to a raw ADC
              (i.e. to compensate for a diode drop).
            minimum: 0
            maximum: 1000000

        required:
          - gw,mode
          - reg
          - label

    required:
      - compatible
      - "#address-cells"
      - "#size-cells"

patternProperties:
  "^fan-controller@[0-9a-f]+$":
    type: object
    description: Optional fan controller

    properties:
      compatible:
        const: gw,gsc-fan

      "#address-cells":
        const: 1

      "#size-cells":
        const: 0

      reg:
        description: The fan controller base address
        maxItems: 1

    required:
      - compatible
      - reg
      - "#address-cells"
      - "#size-cells"

required:
  - compatible
  - reg
  - interrupts
  - interrupt-controller
  - "#interrupt-cells"
  - "#address-cells"
  - "#size-cells"

examples:
  - |
    #include <dt-bindings/gpio/gpio.h>
    i2c {
        #address-cells = <1>;
        #size-cells = <0>;

        gsc@20 {
            compatible = "gw,gsc";
            reg = <0x20>;
            interrupt-parent = <&gpio1>;
            interrupts = <4 GPIO_ACTIVE_LOW>;
            interrupt-controller;
            #interrupt-cells = <1>;
            #address-cells = <1>;
            #size-cells = <0>;

            adc {
                compatible = "gw,gsc-adc";
                #address-cells = <1>;
                #size-cells = <0>;

                channel@0 { /* A0: Board Temperature */
                    reg = <0x00>;
                    label = "temp";
                    gw,mode = <0>;
                };

                channel@2 { /* A1: Input Voltage (raw ADC) */
                    reg = <0x02>;
                    label = "vdd_vin";
                    gw,mode = <1>;
                    gw,voltage-divider-ohms = <22100 1000>;
                    gw,voltage-offset-microvolt = <800000>;
                };

                channel@b { /* A2: Battery voltage */
                    reg = <0x0b>;
                    label = "vdd_bat";
                    gw,mode = <1>;
                };
            };

            fan-controller@2c {
                #address-cells = <1>;
                #size-cells = <0>;
                compatible = "gw,gsc-fan";
                reg = <0x2c>;
            };
        };
    };
+109 −0
Original line number Diff line number Diff line
.. SPDX-License-Identifier: GPL-2.0

Kernel driver amd_energy
==========================

Supported chips:

* AMD Family 17h Processors

  Prefix: 'amd_energy'

  Addresses used:  RAPL MSRs

  Datasheets:

  - Processor Programming Reference (PPR) for AMD Family 17h Model 01h, Revision B1 Processors

	https://developer.amd.com/wp-content/resources/55570-B1_PUB.zip

  - Preliminary Processor Programming Reference (PPR) for AMD Family 17h Model 31h, Revision B0 Processors

	https://developer.amd.com/wp-content/resources/56176_ppr_Family_17h_Model_71h_B0_pub_Rev_3.06.zip

Author: Naveen Krishna Chatradhi <nchatrad@amd.com>

Description
-----------

The Energy driver exposes the energy counters that are
reported via the Running Average Power Limit (RAPL)
Model-specific Registers (MSRs) via the hardware monitor
(HWMON) sysfs interface.

1. Power, Energy and Time Units
   MSR_RAPL_POWER_UNIT/ C001_0299:
   shared with all cores in the socket

2. Energy consumed by each Core
   MSR_CORE_ENERGY_STATUS/ C001_029A:
   32-bitRO, Accumulator, core-level power reporting

3. Energy consumed by Socket
   MSR_PACKAGE_ENERGY_STATUS/ C001_029B:
   32-bitRO, Accumulator, socket-level power reporting,
   shared with all cores in socket

These registers are updated every 1ms and cleared on
reset of the system.

Note: If SMT is enabled, Linux enumerates all threads as cpus.
Since, the energy status registers are accessed at core level,
reading those registers from the sibling threads would result
in duplicate values. Hence, energy counter entries are not
populated for the siblings.

Energy Caluclation
------------------

Energy information (in Joules) is based on the multiplier,
1/2^ESU; where ESU is an unsigned integer read from
MSR_RAPL_POWER_UNIT register. Default value is 10000b,
indicating energy status unit is 15.3 micro-Joules increment.

Reported values are scaled as per the formula

scaled value = ((1/2^ESU) * (Raw value) * 1000000UL) in uJoules

Users calculate power for a given domain by calculating
	dEnergy/dTime for that domain.

Energy accumulation
--------------------------

Current, Socket energy status register is 32bit, assuming a 240W
2P system, the register would wrap around in

	2^32*15.3 e-6/240 * 2 = 547.60833024 secs to wrap(~9 mins)

The Core energy register may wrap around after several days.

To improve the wrap around time, a kernel thread is implemented
to accumulate the socket energy counters and one core energy counter
per run to a respective 64-bit counter. The kernel thread starts
running during probe, wakes up every 100secs and stops running
when driver is removed.

A socket and core energy read would return the current register
value added to the respective energy accumulator.

Sysfs attributes
----------------

=============== ========  =====================================
Attribute	Label	  Description
===============	========  =====================================

* For index N between [1] and [nr_cpus]

===============	========  ======================================
energy[N]_input EcoreX	  Core Energy   X = [0] to [nr_cpus - 1]
			  Measured input core energy
===============	========  ======================================

* For N between [nr_cpus] and [nr_cpus + nr_socks]

===============	========  ======================================
energy[N]_input EsocketX  Socket Energy X = [0] to [nr_socks -1]
			  Measured input socket energy
=============== ========  ======================================
+117 −0
Original line number Diff line number Diff line
.. 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 <maxim.kaurkin@baikalelectronics.ru>
    Serge Semin <Sergey.Semin@baikalelectronics.ru>

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.
=============================== ======= =======================================
+53 −0
Original line number Diff line number Diff line
.. SPDX-License-Identifier: GPL-2.0

Kernel driver gsc-hwmon
=======================

Supported chips: Gateworks GSC
Datasheet: http://trac.gateworks.com/wiki/gsc
Author: Tim Harvey <tharvey@gateworks.com>

Description:
------------

This driver supports hardware monitoring for the temperature sensor,
various ADC's connected to the GSC, and optional FAN controller available
on some boards.


Voltage Monitoring
------------------

The voltage inputs are scaled either internally or by the driver depending
on the GSC version and firmware. The values returned by the driver do not need
further scaling. The voltage input labels provide the voltage rail name:

inX_input                  Measured voltage (mV).
inX_label                  Name of voltage rail.


Temperature Monitoring
----------------------

Temperatures are measured with 12-bit or 10-bit resolution and are scaled
either internally or by the driver depending on the GSC version and firmware.
The values returned by the driver reflect millidegree Celcius:

tempX_input                Measured temperature.
tempX_label                Name of temperature input.


PWM Output Control
------------------

The GSC features 1 PWM output that operates in automatic mode where the
PWM value will be scalled depending on 6 temperature boundaries.
The tempeature boundaries are read-write and in millidegree Celcius and the
read-only PWM values range from 0 (off) to 255 (full speed).
Fan speed will be set to minimum (off) when the temperature sensor reads
less than pwm1_auto_point1_temp and maximum when the temperature sensor
equals or exceeds pwm1_auto_point6_temp.

pwm1_auto_point[1-6]_pwm       PWM value.
pwm1_auto_point[1-6]_temp      Temperature boundary.
Loading