Skip to contentSkip to conversation

PECI device driver introduction

PATCH In review Jae Hyun Yoo 2 participants 18 messages Dec 18, 2019

Subsystems (9)
lore
Share & tools
lore
#0 lore raw

cover PECI device driver introduction

I'm still trying to upstream it but it would take more time so I'm sending it to OpenBMC list to get cherry picked in the meantime.

I rebased it on dev-5.4 branch and it includes fixes for addressing upstream review comments I've got so far.

Below change should be removed from the OpenBMC linux tree before applying it to avoid conflicts:

c31349b9039281107b948bf94ed5e53c235c8081 (ARM: dts: aspeed: peci: Add PECI node)

Thanks,

Jae

Upstreaming cover letter
---------------------------------------------------------------------------
Introduction of the Platform Environment Control Interface (PECI) bus device driver. PECI is a one-wire bus interface that provides a communication channel from Intel processors and chipset components to external monitoring or control devices. PECI is designed to support the following sideband functions:

* Processor and DRAM thermal management
- Processor fan speed control is managed by comparing Digital Thermal Sensor (DTS) thermal readings acquired via PECI against the processor-specific fan speed control reference point, or TCONTROL. Both TCONTROL and DTS thermal readings are accessible via the processor PECI client. These variables are referenced to a common temperature, the TCC activation point, and are both defined as negative offsets from that reference.
- PECI based access to the processor package configuration space provides a means for Baseboard Management Controllers (BMC) or other platform management devices to actively manage the processor and memory power and thermal features.

* Platform Manageability
- Platform manageability functions including thermal, power, and error monitoring. Note that platform 'power' management includes monitoring and control for both the processor and DRAM subsystem to assist with data center power limiting.
- PECI allows read access to certain error registers in the processor MSR space and status monitoring registers in the PCI configuration space within the processor and downstream devices.
- PECI permits writes to certain registers in the processor PCI configuration space.

* Processor Interface Tuning and Diagnostics
- Processor interface tuning and diagnostics capabilities (Intel Interconnect BIST). The processors Intel Interconnect Built In Self Test (Intel IBIST) allows for infield diagnostic capabilities in the Intel UPI and memory controller interfaces. PECI provides a port to execute these diagnostics via its PCI Configuration read and write capabilities.

* Failure Analysis
- Output the state of the processor after a failure for analysis via Crashdump.

PECI uses a single wire for self-clocking and data transfer. The bus requires no additional control lines. The physical layer is a self-clocked one-wire bus that begins each bit with a driven, rising edge from an idle level near zero volts. The duration of the signal driven high depends on whether the bit value is a logic '0' or logic '1'. PECI also includes variable data transfer rate established with every message. In this way, it is highly flexible even though underlying logic is simple.

The interface design was optimized for interfacing between an Intel processor and chipset components in both single processor and multiple processor environments. The single wire interface provides low board routing overhead for the multiple load connections in the congested routing area near the processor and chipset components. Bus speed, error checking, and low protocol overhead provides adequate link bandwidth and reliability to transfer critical device operating conditions and configuration information.

This implementation provides the basic framework to add PECI extensions to the Linux bus and device models. A hardware specific 'Adapter' driver can be attached to the PECI bus to provide sideband functions described above. It is also possible to access all devices on an adapter from userspace through the /dev interface. A device specific 'Client' driver also can be attached to the PECI bus so each processor client's features can be supported by the 'Client' driver through an adapter connection in the bus. This patch set includes Aspeed 24xx/25xx/26xx, NPCM7xx PECI drivers and PECI cputemp/dimmtemp drivers as the first implementation for both adapter and client drivers on the PECI bus framework.

Please review.

Thanks,

Jae

Changes since v11:
- Removed redundant setting in kconfig and added HAS_IOMEM dependency to peci-aspeed and peci-npcm kconfig.
- Simplified PECI cmd idle cheking logic.
- Refined PECI cmd retry logic.
- Fixed to use a define for Intel P6 family.
- Added LE16 conversion for reading DTS.
- Replaced hwmon temperature label table with dynamic table.
- Added CPU model checking code into DIMM temp hwmon driver.
- Fixed style issues.

Changes since v10:
- Split out peci-dev module from peci-core module.
- Changed device tree bindings documents format to DT schema.
- Changed hwmon documents format to rst.
- Added Skylake Xeon D support in PECI hwmon drivers.
- Added DTS temperature reading in peci-cputemp driver which is more thermal control friendlier than Die temperature.
- Added max and crit properties into peci-dimmtemp driver for temperature threshold checking.
- Refined kconfig dependencies in PECI subsystem.
- Added PECI 4.0 command set support.
- Refined 32-bit boundary alignment for all PECI ioctl command structs.
- Added DMA safe command buffer handling in peci-core.
- Added Nuvoton NPCM7xx PECI support.
- Added Aspeed AST26xx PECI support.
- Moved adapter drivers into 'drivers/peci/busses'.
- Fixed minor bugs and style issues.
- configfs support isn't added in this patch set. Will add that using a separate patch set.

Changes since v9:
- Updated license identifiers to incidate 2019.
- Removed unnecessary member variable and enum type from intel client driver.
- Removed 'type' argument from the access_ok() function call.

Changes since v8:
- Refined descriptions in PECI device tree documents.
- Fixed checking logic of supportable PECI commands using full revision number.
- Fixed DIB data size to u64 to make that can contain 8-bytes of information.
- Changed PECI cdev names from pecix to peci-x where x is bus number.
- Refined intel-peci-client driver and moved hwmon relating codes to peci-hwmon.h.
- Added missing core label strings into peci-cputemp driver.
- Added kerneldoc comments.

Changes since v7:
- Fixed a typo in the MFD_INTEL_PECI_CLIENT description.
- Made peci_unregister_device() NULL-aware.
- Converted to using %pOF instead of node full name in peci-core.
- Removed OF tables from peci-cputemp and peci-dimmtemp.
- Removed of_compatible strings from intel-peci-client.
- Added an access_ok() check into peci_ioctl in peci-core.
- Changed the DT node name of peci simple-bus from 'peci' to 'bus'.

Changes since v6:
- Dropped off unnecessary examples from dt-bindings document.
- Fixed a bug in DIMM index mask building logic.
- Modified DIMM temp label strings to match with the way in BIOS.
- Changed PECI ioctl base number from B6 to B7 to avoid conflict with fpga-dfl.
- Separated the PECI section in MAINTAINERS into two parts - PECI subsystem and ASPEED PECI driver.

Changes since v5:
- Added more detailed descriptions for PECI client MFD documents.
- Changed PECI client MFD souce file names.
- Fixed DT example of PECI client MFD.
- Removed unnecessary debug printings.
- Moved the asm/intel-family.h inclusion place.

Changes since v4:
- Fixed an incorrect endianness handling in peci-aspeed.
- Added a comment to explain about the asm/intel-family.h inclusion.
- Added an MFD module to support multi-function PECI client devices.

Changes since v3:
- Made code more simple and compact.
- Removed unused header file inclusion.
- Fixed incorrect error return values and messages.
- Removed DTS margin temperature from the peci-cputemp.
- Made some magic numbers use defines.
- Moved peci_get_cpu_id() into peci-core as a common function.
- Replaced the cancel_delayed_work() call with a cancel_delayed_work_sync().
- Replaced AST and Aspeed uses with ASPEED.
- Simplified peci command timeout checking logic using regmap_read_poll_timeout().
- Simplified endian swap codes using endian handling macros.
- Dropped regmap read/write error checking except for the first access.
- Added a PECI reset setting in the device tree node.
- Removed unnecessary sleep from the probe context.
- Removed IRQF_SHARED flag from irq request code in the ASPEED PECI driver.
- Fixed typos in documents.
- Combined peci-bus.txt, peci-adapter.txt and peci-client.txt into peci.txt.
- Fixed and swept documents to drop some incorrect or unnecessary descriptions.
- Fixed device tree to make unit-address format use reg contents.
- Simplified bit manipulations using <linux/bitfield.h>.
- Made client CPU model checking use <asm/intel-family.h> if available.
- Modified adapter heap allocation method to use kobject reference count based.
- Added the low-level PECI xfer IOCTL again to support the Redfish requirement.
- Added PM domain attach/detach code.
- Added logic for device instantiation through sysfs.
- Fix a bug of interrupt status checking code in peci-aspeed driver.

Changes since v2:
- Divided peci-hwmon driver into two drivers, peci-cputemp and peci-dimmtemp.
- Added generic dt binding documents for PECI bus, adapter and client.
- Removed in_atomic() call from the PECI core driver.
- Improved PECI commands masking logic.
- Added permission check logic for PECI ioctls.
- Removed unnecessary type casts.
- Fixed some invalid error return codes.
- Added the mark_updated() function to improve update interval checking logic.
- Fixed a bug in populated DIMM checking function.
- Fixed some typo, grammar and style issues in documents.
- Rewrote hwmon drivers to use devm_hwmon_device_register_with_info API.
- Made peci_match_id() function as a static.
- Replaced a deprecated create_singlethread_workqueue() call with an alloc_ordered_workqueue() call.
- Reordered local variable definitions in reversed xmas tree notation.
- Listed up client CPUs that can be supported by peci-cputemp and peci-dimmtemp hwmon drivers.
- Added CPU generation detection logic which checks CPUID signature through PECI connection.
- Improved interrupt handling logic in the Aspeed PECI adapter driver.
- Fixed SPDX license identifier style in header files.
- Changed some macros in peci.h to static inline functions.
- Dropped sleepable context checking code in peci-core.
- Adjusted rt_mutex protection scope in peci-core.
- Moved adapter->xfer() checking code into peci_register_adapter().
- Improved PECI command retry checking logic.
- Changed ioctl base from 'P' to 0xb6 to avoid confiliction and updated ioctl-number.txt to reflect the ioctl number of PECI subsystem.
- Added a comment to describe PECI retry action.
- Simplified return code handling of peci_ioctl_ping().
- Changed type of peci_ioctl_fn[] to static const.
- Fixed range checking code for valid PECI commands.
- Fixed the error return code on invalid PECI commands.
- Fixed incorrect definitions of PECI ioctl and its handling logic.

Changes since v1:
- Additionally implemented a core driver to support PECI linux bus driver model.
- Modified Aspeed PECI driver to make that to be an adapter driver in PECI bus.
- Modified PECI hwmon driver to make that to be a client driver in PECI bus.
- Simplified hwmon driver attribute labels and removed redundant strings.
- Removed core_nums from device tree setting of hwmon driver and modified core number detection logic to check the resolved_core register in client CPU's local PCI configuration area.
- Removed dimm_nums from device tree setting of hwmon driver and added populated DIMM detection logic to support dynamic creation.
- Removed indexing gap on core temperature and DIMM temperature attributes.
- Improved hwmon registration and dynamic attribute creation logic.
- Fixed structure definitions in PECI uapi header to make that use __u8, __u16 and etc.
- Modified wait_for_completion_interruptible_timeout error handling logic in Aspeed PECI driver to deliver errors correctly.
- Removed low-level xfer command from ioctl and kept only high-level PECI command suite as ioctls.
- Fixed I/O timeout logic in Aspeed PECI driver using ktime.
- Added a function into hwmon driver to simplify update delay checking.
- Added a function into hwmon driver to convert 10.6 to millidegree.
- Dropped non-standard attributes in hwmon driver.
- Fixed OF table for hwmon to make it indicate as a PECI client of Intel CPU target.
- Added a maintainer of PECI subsystem into MAINTAINERS document.

Jae Hyun Yoo (11):
dt-bindings: Add PECI subsystem document
Documentation: ioctl: Add ioctl numbers for PECI subsystem
peci: Add support for PECI bus driver core
dt-bindings: Add bindings document of Aspeed PECI adapter
ARM: dts: aspeed: Add PECI node
peci: Add Aspeed PECI adapter driver
dt-bindings: mfd: Add Intel PECI client bindings document
mfd: intel-peci-client: Add Intel PECI client driver
Documentation: hwmon: Add documents for PECI hwmon drivers
hwmon: Add PECI cputemp driver
hwmon: Add PECI dimmtemp driver

Tomer Maimon (3):
dt-bindings: peci: add NPCM PECI documentation
ARM: dts: npcm7xx: Add PECI node
peci: npcm: add NPCM PECI driver

 .../bindings/mfd/intel,peci-client.yaml       |   67 +
 .../devicetree/bindings/peci/peci-aspeed.yaml |  124 +
 .../devicetree/bindings/peci/peci-bus.yaml    |  129 +
 .../devicetree/bindings/peci/peci-client.yaml |   54 +
 .../devicetree/bindings/peci/peci-npcm.yaml   |  102 +
 Documentation/hwmon/index.rst                 |    2 +
 Documentation/hwmon/peci-cputemp.rst          |   95 +
 Documentation/hwmon/peci-dimmtemp.rst         |   60 +
 Documentation/ioctl/ioctl-number.rst          |    2 +
 arch/arm/boot/dts/aspeed-g4.dtsi              |   25 +
 arch/arm/boot/dts/aspeed-g5.dtsi              |   25 +
 arch/arm/boot/dts/aspeed-g6.dtsi              |   25 +
 arch/arm/boot/dts/nuvoton-common-npcm7xx.dtsi |   23 +-
 drivers/Kconfig                               |    2 +
 drivers/Makefile                              |    1 +
 drivers/hwmon/Kconfig                         |   28 +
 drivers/hwmon/Makefile                        |    2 +
 drivers/hwmon/peci-cputemp.c                  |  472 ++++
 drivers/hwmon/peci-dimmtemp.c                 |  425 ++++
 drivers/hwmon/peci-hwmon.h                    |   48 +
 drivers/mfd/Kconfig                           |   17 +
 drivers/mfd/Makefile                          |    1 +
 drivers/mfd/intel-peci-client.c               |  148 ++
 drivers/peci/Kconfig                          |   37 +
 drivers/peci/Makefile                         |   11 +
 drivers/peci/busses/Kconfig                   |   34 +
 drivers/peci/busses/Makefile                  |    7 +
 drivers/peci/busses/peci-aspeed.c             |  484 ++++
 drivers/peci/busses/peci-npcm.c               |  406 ++++
 drivers/peci/peci-core.c                      | 2089 +++++++++++++++++
 drivers/peci/peci-dev.c                       |  348 +++
 include/linux/mfd/intel-peci-client.h         |  119 +
 include/linux/peci.h                          |  150 ++
 include/uapi/linux/peci-ioctl.h               |  661 ++++++
 34 files changed, 6216 insertions(+), 7 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/intel,peci-client.yaml
 create mode 100644 Documentation/devicetree/bindings/peci/peci-aspeed.yaml
 create mode 100644 Documentation/devicetree/bindings/peci/peci-bus.yaml
 create mode 100644 Documentation/devicetree/bindings/peci/peci-client.yaml
 create mode 100644 Documentation/devicetree/bindings/peci/peci-npcm.yaml
 create mode 100644 Documentation/hwmon/peci-cputemp.rst
 create mode 100644 Documentation/hwmon/peci-dimmtemp.rst
 create mode 100644 drivers/hwmon/peci-cputemp.c
 create mode 100644 drivers/hwmon/peci-dimmtemp.c
 create mode 100644 drivers/hwmon/peci-hwmon.h
 create mode 100644 drivers/mfd/intel-peci-client.c
 create mode 100644 drivers/peci/Kconfig
 create mode 100644 drivers/peci/Makefile
 create mode 100644 drivers/peci/busses/Kconfig
 create mode 100644 drivers/peci/busses/Makefile
 create mode 100644 drivers/peci/busses/peci-aspeed.c
 create mode 100644 drivers/peci/busses/peci-npcm.c
 create mode 100644 drivers/peci/peci-core.c
 create mode 100644 drivers/peci/peci-dev.c
 create mode 100644 include/linux/mfd/intel-peci-client.h
 create mode 100644 include/linux/peci.h
 create mode 100644 include/uapi/linux/peci-ioctl.h
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/14 dt-bindings: Add PECI subsystem document

This commit adds PECI subsystem document.

---
Changes since v11:
- None

Changes since v10:
- Changed documents format to DT schema format so I dropped all review tags. Please review it again.

 .../devicetree/bindings/peci/peci-bus.yaml    | 129 ++++++++++++++++++
 .../devicetree/bindings/peci/peci-client.yaml |  54 ++++++++
 2 files changed, 183 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/peci/peci-bus.yaml
 create mode 100644 Documentation/devicetree/bindings/peci/peci-client.yaml
Documentation/devicetree/bindings/peci/peci-bus.yaml new file +129 -0
new file mode 100644
index 000000000000..b085e67089cf
@@ -0,0 +1,129 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/peci/peci-bus.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Generic Device Tree Bindings for PECI bus
+
+maintainers:
+  - Jae Hyun Yoo <[email protected]>
+
+description: |
+  PECI (Platform Environment Control Interface) is a one-wire bus interface that
+  provides a communication channel from Intel processors and chipset components
+  to external monitoring or control devices. PECI is designed to support the
+  following sideband functions:
+
+  * Processor and DRAM thermal management
+    - Processor fan speed control is managed by comparing Digital Thermal
+      Sensor (DTS) thermal readings acquired via PECI against the
+      processor-specific fan speed control reference point, or TCONTROL. Both
+      TCONTROL and DTS thermal readings are accessible via the processor PECI
+      client. These variables are referenced to a common temperature, the TCC
+      activation point, and are both defined as negative offsets from that
+      reference.
+    - PECI based access to the processor package configuration space provides
+      a means for Baseboard Management Controllers (BMC) or other platform
+      management devices to actively manage the processor and memory power
+      and thermal features.
+
+  * Platform Manageability
+    - Platform manageability functions including thermal, power, and error
+      monitoring. Note that platform 'power' management includes monitoring
+      and control for both the processor and DRAM subsystem to assist with
+      data center power limiting.
+    - PECI allows read access to certain error registers in the processor MSR
+      space and status monitoring registers in the PCI configuration space
+      within the processor and downstream devices.
+    - PECI permits writes to certain registers in the processor PCI
+      configuration space.
+
+  * Processor Interface Tuning and Diagnostics
+    - Processor interface tuning and diagnostics capabilities
+      (Intel Interconnect BIST). The processors Intel Interconnect Built In
+      Self Test (Intel IBIST) allows for infield diagnostic capabilities in
+      the Intel UPI and memory controller interfaces. PECI provides a port to
+      execute these diagnostics via its PCI Configuration read and write
+      capabilities.
+
+  * Failure Analysis
+    - Output the state of the processor after a failure for analysis via
+      Crashdump.
+
+  PECI uses a single wire for self-clocking and data transfer. The bus
+  requires no additional control lines. The physical layer is a self-clocked
+  one-wire bus that begins each bit with a driven, rising edge from an idle
+  level near zero volts. The duration of the signal driven high depends on
+  whether the bit value is a logic '0' or logic '1'. PECI also includes
+  variable data transfer rate established with every message. In this way, it
+  is highly flexible even though underlying logic is simple.
+
+  The interface design was optimized for interfacing between an Intel
+  processor and chipset components in both single processor and multiple
+  processor environments. The single wire interface provides low board
+  routing overhead for the multiple load connections in the congested routing
+  area near the processor and chipset components. Bus speed, error checking,
+  and low protocol overhead provides adequate link bandwidth and reliability
+  to transfer critical device operating conditions and configuration
+  information.
+
+  PECI subsystem provides single or multiple bus nodes support so each bus can
+  have one adapter node and multiple device specific client nodes that can be
+  attached to the PECI bus so each processor client's features can be supported
+  by the client node through an adapter connection in the bus.
+
+properties:
+  compatible:
+    const: simple-bus
+
+  "#address-cells":
+    # Required to define bus device control resource address.
+    const: 1
+
+  "#size-cells":
+    # Required to define bus device control resource address.
+    const: 1
+
+  ranges: true
+
+required:
+  - compatible
+  - "#address-cells"
+  - "#size-cells"
+  - ranges
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/clock/ast2600-clock.h>
+    peci: bus@1e78b000 {
+        compatible = "simple-bus";
+        #address-cells = <1>;
+        #size-cells = <1>;
+        ranges = <0x0 0x1e78b000 0x200>;
+
+        peci0: peci-bus@0 {
+            compatible = "aspeed,ast2600-peci";
+            reg = <0x0 0x100>;
+            #address-cells = <1>;
+            #size-cells = <0>;
+            interrupts = <GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>;
+            clocks = <&syscon ASPEED_CLK_GATE_REF0CLK>;
+            resets = <&syscon ASPEED_RESET_PECI>;
+            clock-frequency = <24000000>;
+        };
+
+        // Just an example. ast2600 doesn't have a second PECI module actually.
+        peci1: peci-bus@100 {
+            compatible = "aspeed,ast2600-peci";
+            reg = <0x100 0x100>;
+            #address-cells = <1>;
+            #size-cells = <0>;
+            interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>;
+            clocks = <&syscon ASPEED_CLK_GATE_REF0CLK>;
+            resets = <&syscon ASPEED_RESET_PECI>;
+            clock-frequency = <24000000>;
+        };
+    };
+...
Documentation/devicetree/bindings/peci/peci-client.yaml new file +54 -0

54 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/14 Documentation: ioctl: Add ioctl numbers for PECI subsystem

In reply to Jae Hyun Yoo

This commit updates ioctl-number.rst to reflect ioctl numbers used by the PECI subsystem.

---
Changes since v11:
- None

Changes since v10:
- Moved the change from 'Documentation/ioctl/ioctl-number.txt.

 Documentation/userspace-api/ioctl/ioctl-number.rst | 2 ++
 1 file changed, 2 insertions(+)
Documentation/ioctl/ioctl-number.rst +2 -0
index bef79cd4c6b4..de23fc0f0fce
@@ -337,6 +337,8 @@ Code  Seq#    Include File                                           Comments
 0xB4  00-0F  linux/gpio.h                                            <mailto:[email protected]>
 0xB5  00-0F  uapi/linux/rpmsg.h                                      <mailto:[email protected]>
 0xB6  all    linux/fpga-dfl.h
+0xB7  all    uapi/linux/peci-ioctl.h                                 PECI subsystem
+                                                                     <mailto:[email protected]>
 0xC0  00-0F  linux/usb/iowarrior.h
 0xCA  00-0F  uapi/misc/cxl.h
 0xCA  10-2F  uapi/misc/ocxl.h
Signature · 1 line
2.17.1
#3 lore raw

PATCH 3/14 peci: Add support for PECI bus driver core

In reply to Jae Hyun Yoo

This commit adds driver implementation for PECI bus core into linux driver framework.

PECI (Platform Environment Control Interface) is a one-wire bus interface that provides a communication channel from Intel processors and chipset components to external monitoring or control devices. PECI is designed to support the following sideband functions:

* Processor and DRAM thermal management
- Processor fan speed control is managed by comparing Digital Thermal Sensor (DTS) thermal readings acquired via PECI against the processor-specific fan speed control reference point, or TCONTROL. Both TCONTROL and DTS thermal readings are accessible via the processor PECI client. These variables are referenced to a common temperature, the TCC activation point, and are both defined as negative offsets from that reference.
- PECI based access to the processor package configuration space provides a means for Baseboard Management Controllers (BMC) or other platform management devices to actively manage the processor and memory power and thermal features.

* Platform Manageability
- Platform manageability functions including thermal, power, and error monitoring. Note that platform 'power' management includes monitoring and control for both the processor and DRAM subsystem to assist with data center power limiting.
- PECI allows read access to certain error registers in the processor MSR space and status monitoring registers in the PCI configuration space within the processor and downstream devices.
- PECI permits writes to certain registers in the processor PCI configuration space.

* Processor Interface Tuning and Diagnostics
- Processor interface tuning and diagnostics capabilities (Intel Interconnect BIST). The processors Intel Interconnect Built In Self Test (Intel IBIST) allows for infield diagnostic capabilities in the Intel UPI and memory controller interfaces. PECI provides a port to execute these diagnostics via its PCI Configuration read and write capabilities.

* Failure Analysis
- Output the state of the processor after a failure for analysis via Crashdump.

PECI uses a single wire for self-clocking and data transfer. The bus requires no additional control lines. The physical layer is a self-clocked one-wire bus that begins each bit with a driven, rising edge from an idle level near zero volts. The duration of the signal driven high depends on whether the bit value is a logic '0' or logic '1'. PECI also includes variable data transfer rate established with every message. In this way, it is highly flexible even though underlying logic is simple.

The interface design was optimized for interfacing between an Intel processor and chipset components in both single processor and multiple processor environments. The single wire interface provides low board routing overhead for the multiple load connections in the congested routing area near the processor and chipset components. Bus speed, error checking, and low protocol overhead provides adequate link bandwidth and reliability to transfer critical device operating conditions and configuration information.

This implementation provides the basic framework to add PECI extensions to the Linux bus and device models. A hardware specific 'Adapter' driver can be attached to the PECI bus to provide sideband functions described above. It is also possible to access all devices on an adapter from userspace through the /dev interface. A device specific 'Client' driver also can be attached to the PECI bus so each processor client's features can be supported by the 'Client' driver through an adapter connection in the bus.

---
Changes since v11:
- Refined PECI cmd retry logic.
- Fixed style issues.

Changes since v10:
- Split out peci-dev module from peci-core module.
- Added PECI 4.0 command set support.
- Refined 32-bit boundary alignment for all PECI ioctl command structs.
- Added DMA safe command buffer handling in peci-core.
- Refined kconfig dependencies in PECI subsystem.
- Fixed minor bugs and style issues.
- configfs support isn't added in this patch set. Will add that using a separate patch set.

 drivers/Kconfig                 |    2 +
 drivers/Makefile                |    1 +
 drivers/peci/Kconfig            |   37 +
 drivers/peci/Makefile           |   11 +
 drivers/peci/busses/Kconfig     |    7 +
 drivers/peci/busses/Makefile    |    4 +
 drivers/peci/peci-core.c        | 2089 +++++++++++++++++++++++++++++++
 drivers/peci/peci-dev.c         |  348 +++++
 include/linux/peci.h            |  150 +++
 include/uapi/linux/peci-ioctl.h |  661 ++++++++++
 10 files changed, 3310 insertions(+)
 create mode 100644 drivers/peci/Kconfig
 create mode 100644 drivers/peci/Makefile
 create mode 100644 drivers/peci/busses/Kconfig
 create mode 100644 drivers/peci/busses/Makefile
 create mode 100644 drivers/peci/peci-core.c
 create mode 100644 drivers/peci/peci-dev.c
 create mode 100644 include/linux/peci.h
 create mode 100644 include/uapi/linux/peci-ioctl.h
drivers/Kconfig +2 -0
index 8befa53f43be..4322efa37732 100644
@@ -228,4 +228,6 @@ source "drivers/interconnect/Kconfig"
 
 source "drivers/counter/Kconfig"
 
+source "drivers/peci/Kconfig"
+
 endmenu
drivers/Makefile +1 -0
index aaef17cc6512..82f78cfedf69 100644
@@ -186,3 +186,4 @@ obj-$(CONFIG_SIOX)		+= siox/
 obj-$(CONFIG_GNSS)		+= gnss/
 obj-$(CONFIG_INTERCONNECT)	+= interconnect/
 obj-$(CONFIG_COUNTER)		+= counter/
+obj-$(CONFIG_PECI)		+= peci/
drivers/peci/Kconfig new file +37 -0
new file mode 100644
index 000000000000..a64fed7bb367
@@ -0,0 +1,37 @@
+#
+# Platform Environment Control Interface (PECI) subsystem configuration
+#
+
+menu "PECI support"
+
+config PECI
+	tristate "PECI support"
+	select CRC8
+	help
+	  The Platform Environment Control Interface (PECI) is a one-wire bus
+	  interface that provides a communication channel from Intel processors
+	  and chipset components to external monitoring or control devices.
+
+	  If you want PECI support, you should say Y here and also to the
+	  specific driver for your bus adapter(s) below.
+
+	  This support is also available as a module. If so, the module
+	  will be called peci-core.
+
+if PECI
+
+config PECI_CHARDEV
+	tristate "PECI device interface"
+	help
+	  Say Y here to use peci-* device files, usually found in the /dev
+	  directory on your system. They make it possible to have user-space
+	  programs use the PECI bus.
+
+	  This support is also available as a module. If so, the module
+	  will be called peci-dev.
+
+source "drivers/peci/busses/Kconfig"
+
+endif # PECI
+
+endmenu
drivers/peci/Makefile new file +11 -0
new file mode 100644
index 000000000000..da8b0a33fa42
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Makefile for the PECI core drivers.
+#
+
+# Core functionality
+obj-$(CONFIG_PECI)		+= peci-core.o
+obj-$(CONFIG_PECI_CHARDEV)	+= peci-dev.o
+
+# Hardware specific bus drivers
+obj-y				+= busses/
drivers/peci/busses/Kconfig new file +7 -0
new file mode 100644
index 000000000000..d7e064f52a1c
@@ -0,0 +1,7 @@
+#
+# PECI hardware bus configuration
+#
+
+menu "PECI Hardware Bus support"
+
+endmenu
drivers/peci/busses/Makefile new file +4 -0
new file mode 100644
index 000000000000..9e9334fee297
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Makefile for the PECI hardware bus drivers.
+#
drivers/peci/peci-core.c new file +2089 -0

2,089 lines not on this page · raw message

drivers/peci/peci-dev.c new file +348 -0

348 lines not on this page · raw message

include/linux/peci.h new file +150 -0

150 lines not on this page · raw message

include/uapi/linux/peci-ioctl.h new file +661 -0

344 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.17.1

Part of the diff is not shown here. View the raw message.

#4 lore raw

PATCH 4/14 dt-bindings: Add bindings document of Aspeed PECI adapter

In reply to Jae Hyun Yoo

This commit adds bindings document of Aspeed PECI adapter for ASPEED AST24xx/25xx/26xx SoCs.

---
Changes since v11:
- None

Changes since v10:
- Changed documents format to DT schema format so I dropped all review tags. Please review it again.

 .../devicetree/bindings/peci/peci-aspeed.yaml | 124 ++++++++++++++++++
 1 file changed, 124 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/peci/peci-aspeed.yaml
Documentation/devicetree/bindings/peci/peci-aspeed.yaml new file +124 -0
new file mode 100644
index 000000000000..0f5c2993fe9b
@@ -0,0 +1,124 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/peci/peci-aspeed.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Aspeed PECI Bus Device Tree Bindings
+
+maintainers:
+  - Jae Hyun Yoo <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - aspeed,ast2400-peci
+      - aspeed,ast2500-peci
+      - aspeed,ast2600-peci
+
+  reg:
+    maxItems: 1
+
+  "#address-cells":
+    # Required to define a client address.
+    const: 1
+
+  "#size-cells":
+    # Required to define a client address.
+    const: 0
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    description: |
+      Clock source for PECI controller. Should reference the external
+      oscillator clock.
+    maxItems: 1
+
+  resets:
+    maxItems: 1
+
+  clock-frequency:
+    # Operation frequency of PECI controller in units of Hz.
+    minimum: 187500
+    maximum: 24000000
+
+  msg-timing:
+    description: |
+      Message timing negotiation period. This value will determine the period
+      of message timing negotiation to be issued by PECI controller. The unit
+      of the programmed value is four times of PECI clock period.
+    allOf:
+      - $ref: /schemas/types.yaml#/definitions/uint32
+      - minimum: 0
+        maximum: 255
+        default: 1
+
+  addr-timing:
+    description: |
+      Address timing negotiation period. This value will determine the period
+      of address timing negotiation to be issued by PECI controller. The unit
+      of the programmed value is four times of PECI clock period.
+    allOf:
+      - $ref: /schemas/types.yaml#/definitions/uint32
+      - minimum: 0
+        maximum: 255
+        default: 1
+
+  rd-sampling-point:
+    description: |
+      Read sampling point selection. The whole period of a bit time will be
+      divided into 16 time frames. This value will determine the time frame
+      in which the controller will sample PECI signal for data read back.
+      Usually in the middle of a bit time is the best.
+    allOf:
+      - $ref: /schemas/types.yaml#/definitions/uint32
+      - minimum: 0
+        maximum: 15
+        default: 8
+
+  cmd-timeout-ms:
+    # Command timeout in units of ms.
+    allOf:
+      - $ref: /schemas/types.yaml#/definitions/uint32
+      - minimum: 1
+        maximum: 60000
+        default: 1000
+
+required:
+  - compatible
+  - reg
+  - "#address-cells"
+  - "#size-cells"
+  - interrupts
+  - clocks
+  - resets
+  - clock-frequency
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/clock/ast2600-clock.h>
+    peci: bus@1e78b000 {
+        compatible = "simple-bus";
+        #address-cells = <1>;
+        #size-cells = <1>;
+        ranges = <0x0 0x1e78b000 0x60>;
+
+        peci0: peci-bus@0 {
+            compatible = "aspeed,ast2600-peci";
+            reg = <0x0 0x100>;
+            #address-cells = <1>;
+            #size-cells = <0>;
+            interrupts = <GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>;
+            clocks = <&syscon ASPEED_CLK_GATE_REF0CLK>;
+            resets = <&syscon ASPEED_RESET_PECI>;
+            clock-frequency = <24000000>;
+            msg-timing = <1>;
+            addr-timing = <1>;
+            rd-sampling-point = <8>;
+            cmd-timeout-ms = <1000>;
+        };
+    };
+...
Signature · 1 line
2.17.1
#5 lore raw

PATCH 5/14 ARM: dts: aspeed: Add PECI node

In reply to Jae Hyun Yoo

This commit adds PECI bus/adapter node into aspeed-g4, aspeed-g5 and aspeed-g6.

---
Changes since v11:
- None

Changes since v10:
- Added PECI node for Aspeed AST2600.

 arch/arm/boot/dts/aspeed-g4.dtsi | 25 +++++++++++++++++++++++++
 arch/arm/boot/dts/aspeed-g5.dtsi | 25 +++++++++++++++++++++++++
 arch/arm/boot/dts/aspeed-g6.dtsi | 25 +++++++++++++++++++++++++
 3 files changed, 75 insertions(+)
arch/arm/boot/dts/aspeed-g4.dtsi +25 -0
index 71b0adbec402..b875c0785833 100644
@@ -382,6 +382,13 @@
 				};
 			};
 
+			peci: bus@1e78b000 {
+				compatible = "simple-bus";
+				#address-cells = <1>;
+				#size-cells = <1>;
+				ranges = <0x0 0x1e78b000 0x60>;
+			};
+
 			uart2: serial@1e78d000 {
 				compatible = "ns16550a";
 				reg = <0x1e78d000 0x20>;
@@ -425,6 +432,24 @@
 	};
 };
 
+&peci {
+	peci0: peci-bus@0 {
+		compatible = "aspeed,ast2400-peci";
+		reg = <0x0 0x60>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		interrupts = <15>;
+		clocks = <&syscon ASPEED_CLK_GATE_REFCLK>;
+		resets = <&syscon ASPEED_RESET_PECI>;
+		clock-frequency = <24000000>;
+		msg-timing = <1>;
+		addr-timing = <1>;
+		rd-sampling-point = <8>;
+		cmd-timeout-ms = <1000>;
+		status = "disabled";
+	};
+};
+
 &i2c {
 	i2c_ic: interrupt-controller@0 {
 		#interrupt-cells = <1>;
arch/arm/boot/dts/aspeed-g5.dtsi +25 -0
index 0c1e0a268d77..6580b232771e 100644
@@ -499,6 +499,13 @@
 				};
 			};
 
+			peci: bus@1e78b000 {
+				compatible = "simple-bus";
+				#address-cells = <1>;
+				#size-cells = <1>;
+				ranges = <0x0 0x1e78b000 0x60>;
+			};
+
 			uart2: serial@1e78d000 {
 				compatible = "ns16550a";
 				reg = <0x1e78d000 0x20>;
@@ -542,6 +549,24 @@
 	};
 };
 
+&peci {
+	peci0: peci-bus@0 {
+		compatible = "aspeed,ast2500-peci";
+		reg = <0x0 0x60>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		interrupts = <15>;
+		clocks = <&syscon ASPEED_CLK_GATE_REFCLK>;
+		resets = <&syscon ASPEED_RESET_PECI>;
+		clock-frequency = <24000000>;
+		msg-timing = <1>;
+		addr-timing = <1>;
+		rd-sampling-point = <8>;
+		cmd-timeout-ms = <1000>;
+		status = "disabled";
+	};
+};
+
 &i2c {
 	i2c_ic: interrupt-controller@0 {
 		#interrupt-cells = <1>;
arch/arm/boot/dts/aspeed-g6.dtsi +25 -0
index 925c70c40257..2af9efa1faa1 100644
@@ -391,6 +391,13 @@
 				status = "disabled";
 			};
 
+			peci: bus@1e78b000 {
+				compatible = "simple-bus";
+				#address-cells = <1>;
+				#size-cells = <1>;
+				ranges = <0x0 0x1e78b000 0x100>;
+			};
+
 			lpc: lpc@1e789000 {
 				compatible = "aspeed,ast2600-lpc", "simple-mfd";
 				reg = <0x1e789000 0x1000>;
@@ -605,6 +612,24 @@
 
 #include "aspeed-g6-pinctrl.dtsi"
 
+&peci {
+	peci0: peci-bus@0 {
+		compatible = "aspeed,ast2600-peci";
+		reg = <0x0 0x100>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		interrupts = <GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&syscon ASPEED_CLK_GATE_REF0CLK>;
+		resets = <&syscon ASPEED_RESET_PECI>;
+		clock-frequency = <24000000>;
+		msg-timing = <1>;
+		addr-timing = <1>;
+		rd-sampling-point = <8>;
+		cmd-timeout-ms = <1000>;
+		status = "disabled";
+	};
+};
+
 &i2c {
 	i2c0: i2c-bus@80 {
 		#address-cells = <1>;
Signature · 1 line
2.17.1
#6 lore raw

PATCH 6/14 peci: Add Aspeed PECI adapter driver

In reply to Jae Hyun Yoo

This commit adds Aspeed PECI adapter driver for Aspeed AST24xx/25xx/26xx SoCs.

---
Changes since v11:
- Added HAS_IOMEM dependency in kconfig.
- Simplified PECI cmd idle cheking logic.
- Fixed style issues.

Changes since v10:
- Moved driver into 'drivers/peci/busses'.
- Fixed minor bugs.

 drivers/peci/busses/Kconfig       |  13 +
 drivers/peci/busses/Makefile      |   2 +
 drivers/peci/busses/peci-aspeed.c | 484 ++++++++++++++++++++++++++++++
 3 files changed, 499 insertions(+)
 create mode 100644 drivers/peci/busses/peci-aspeed.c
drivers/peci/busses/Kconfig +13 -0
index d7e064f52a1c..ba0b05b29100 100644
@@ -4,4 +4,17 @@
 
 menu "PECI Hardware Bus support"
 
+config PECI_ASPEED
+	tristate "ASPEED PECI support"
+	depends on ARCH_ASPEED || COMPILE_TEST
+	depends on OF
+	depends on HAS_IOMEM
+	depends on PECI
+	help
+	  Say Y here if you want support for the Platform Environment Control
+	  Interface (PECI) bus adapter driver on the ASPEED SoCs.
+
+	  This support is also available as a module. If so, the module
+	  will be called peci-aspeed.
+
 endmenu
drivers/peci/busses/Makefile +2 -0
index 9e9334fee297..69e31dfaca19 100644
@@ -2,3 +2,5 @@
 #
 # Makefile for the PECI hardware bus drivers.
 #
+
+obj-$(CONFIG_PECI_ASPEED)	+= peci-aspeed.o
drivers/peci/busses/peci-aspeed.c new file +484 -0

484 lines not on this page · raw message

Signature · 1 line
2.17.1
#7 lore raw

PATCH 7/14 dt-bindings: peci: add NPCM PECI documentation

In reply to Jae Hyun Yoo

From: Tomer Maimon <[email protected]>

Added device tree binding documentation for Nuvoton BMC NPCM Platform Environment Control Interface(PECI).

---
Changes since v11:
- None

Changes since v10:
- Newly added in v11.

 .../devicetree/bindings/peci/peci-npcm.yaml   | 102 ++++++++++++++++++
 1 file changed, 102 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/peci/peci-npcm.yaml
Documentation/devicetree/bindings/peci/peci-npcm.yaml new file +102 -0
new file mode 100644
index 000000000000..bcd5626e68e7
@@ -0,0 +1,102 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/peci/peci-npcm.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Nuvoton NPCM PECI Bus Device Tree Bindings
+
+maintainers:
+  - Tomer Maimon <[email protected]>
+
+properties:
+  compatible:
+    const: nuvoton,npcm750-peci # for the NPCM7XX BMC.
+
+  reg:
+    maxItems: 1
+
+  "#address-cells":
+    # Required to define a client address.
+    const: 1
+
+  "#size-cells":
+    # Required to define a client address.
+    const: 0
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    # PECI reference clock.
+    maxItems: 1
+
+  cmd-timeout-ms:
+    # Command timeout in units of ms.
+    allOf:
+      - $ref: /schemas/types.yaml#/definitions/uint32
+      - minimum: 1
+        maximum: 60000
+        default: 1000
+
+  pull-down:
+    description: |
+      Defines the PECI I/O internal pull down operation.
+        0: pull down always enable
+        1: pull down only during transactions.
+        2: pull down always disable.
+    allOf:
+      - $ref: /schemas/types.yaml#/definitions/uint32
+      - minimum: 0
+        maximum: 2
+        default: 0
+
+  host-neg-bit-rate:
+    description: |
+      Define host negotiation bit rate divider.
+      the host negotiation bit rate calculate with formula:
+      clock frequency[Hz] / [4 x {host-neg-bit-rate + 1}]
+    allOf:
+      - $ref: /schemas/types.yaml#/definitions/uint32
+      - minimum: 7
+        maximum: 31
+        default: 15
+
+  high-volt-range:
+    description: |
+      Adapts PECI I/O interface to voltage range.
+        0: PECI I/O interface voltage range of 0.8-1.06V (default)
+        1: PECI I/O interface voltage range of 0.95-1.26V
+    type: boolean
+
+required:
+  - compatible
+  - reg
+  - "#address-cells"
+  - "#size-cells"
+  - interrupts
+  - clocks
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/clock/nuvoton,npcm7xx-clock.h>
+    peci: bus@100000 {
+        compatible = "simple-bus";
+        #address-cells = <1>;
+        #size-cells = <1>;
+        ranges = <0x0 0x100000 0x200>;
+
+        peci0: peci-bus@0 {
+            compatible = "nuvoton,npcm750-peci";
+            reg = <0x0 0x200>;
+            #address-cells = <1>;
+            #size-cells = <0>;
+            interrupts = <GIC_SPI 6 IRQ_TYPE_LEVEL_HIGH>;
+            clocks = <&clk NPCM7XX_CLK_APB3>;
+            cmd-timeout-ms = <1000>;
+            pull-down = <0>;
+            host-neg-bit-rate = <15>;
+        };
+    };
+...
Signature · 1 line
2.17.1
#8 lore raw

PATCH 8/14 ARM: dts: npcm7xx: Add PECI node

In reply to Jae Hyun Yoo

From: Tomer Maimon <[email protected]>

This commit adds PECI node for npcm7xx.

---
Changes since v11:
- None

Changes since v10:
- Newly added in v11.

 arch/arm/boot/dts/nuvoton-common-npcm7xx.dtsi | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
arch/arm/boot/dts/nuvoton-common-npcm7xx.dtsi +16 -7
index da02aa70df06..72841f54deb4
@@ -345,14 +345,11 @@
 				};
 			};
 
-			peci: peci-bus@100000 {
-				compatible = "nuvoton,npcm750-peci";
-				reg = <0x100000 0x200>;
+			peci: bus@100000 {
+				compatible = "simple-bus";
 				#address-cells = <1>;
-				#size-cells = <0>;
-				interrupts = <GIC_SPI 6 IRQ_TYPE_LEVEL_HIGH>;
-				clocks = <&clk NPCM7XX_CLK_APB3>;
-				status = "disabled";
+				#size-cells = <1>;
+				ranges = <0x0 0x100000 0x200>;
 			};
 
 			spi0: spi@200000 {
@@ -1257,3 +1254,15 @@
 		};
 	};
 };
+
+&peci {
+	peci0: peci-bus@0 {
+		compatible = "nuvoton,npcm750-peci";
+		reg = <0x0 0x200>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		interrupts = <GIC_SPI 6 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&clk NPCM7XX_CLK_APB3>;
+		status = "disabled";
+	};
+};
Signature · 1 line
2.17.1
#9 lore raw

PATCH 9/14 peci: npcm: add NPCM PECI driver

In reply to Jae Hyun Yoo

From: Tomer Maimon <[email protected]>

Add support for the Nuvoton NPCM BMC hardware to the Platform Environment Control Interface (PECI) subsystem.

---
Changes since v11:
- Added HAS_IOMEM dependency to kconfig.
- Fixed style issues.

- Fixed style issues.

Changes since v10:
- Newly added in v11.

 drivers/peci/busses/Kconfig     |  14 ++
 drivers/peci/busses/Makefile    |   1 +
 drivers/peci/busses/peci-npcm.c | 406 ++++++++++++++++++++++++++++++++
 3 files changed, 421 insertions(+)
 create mode 100644 drivers/peci/busses/peci-npcm.c
drivers/peci/busses/Kconfig +14 -0
index ba0b05b29100..4316234db67c 100644
@@ -17,4 +17,18 @@ config PECI_ASPEED
 	  This support is also available as a module. If so, the module
 	  will be called peci-aspeed.
 
+config PECI_NPCM
+	tristate "Nuvoton NPCM PECI support"
+	select REGMAP_MMIO
+	depends on OF
+	depends on HAS_IOMEM
+	depends on ARCH_NPCM || COMPILE_TEST
+	depends on PECI
+	help
+	  Say Y here if you want support for the Platform Environment Control
+	  Interface (PECI) bus adapter driver on the Nuvoton NPCM SoCs.
+
+	  This support is also available as a module. If so, the module
+	  will be called peci-npcm.
+
 endmenu
drivers/peci/busses/Makefile +1 -0
index 69e31dfaca19..aa8ce3ae5947 100644
@@ -4,3 +4,4 @@
 #
 
 obj-$(CONFIG_PECI_ASPEED)	+= peci-aspeed.o
+obj-$(CONFIG_PECI_NPCM)		+= peci-npcm.o
drivers/peci/busses/peci-npcm.c new file +406 -0

406 lines not on this page · raw message

Signature · 1 line
2.17.1
#10 lore raw

PATCH 10/14 dt-bindings: mfd: Add Intel PECI client bindings document

In reply to Jae Hyun Yoo

This commit adds Intel PECI client bindings document.

---
Changes since v11:
- None

Changes since v10:
- Changed documents format to DT schema format so I dropped all review tags. Please review it again.

 .../bindings/mfd/intel,peci-client.yaml       | 67 +++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/intel,peci-client.yaml
Documentation/devicetree/bindings/mfd/intel,peci-client.yaml new file +67 -0
new file mode 100644
index 000000000000..7baddce0a92c
@@ -0,0 +1,67 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/intel,peci-client.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Intel PECI Client Device Tree Bindings
+
+maintainers:
+  - Jae Hyun Yoo <[email protected]>
+
+description: |
+  PECI (Platform Environment Control Interface) is a one-wire bus interface
+  that provides a communication channel from PECI clients in Intel processors
+  and chipset components to external monitoring or control devices. PECI is
+  designed to support the following sideband functions:
+  - Processor and DRAM thermal management
+  - Platform Manageability
+  - Processor Interface Tuning and Diagnostics
+  - Failure Analysis
+
+properties:
+  compatible:
+    const: intel,peci-client
+
+  reg:
+    description: |
+      Address of a client CPU. According to the PECI specification, client
+      addresses start from 0x30.
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/clock/ast2600-clock.h>
+    peci: bus@1e78b000 {
+        compatible = "simple-bus";
+        #address-cells = <1>;
+        #size-cells = <1>;
+        ranges = <0x0 0x1e78b000 0x60>;
+
+        peci0: peci-bus@0 {
+            compatible = "aspeed,ast2600-peci";
+            reg = <0x0 0x100>;
+            #address-cells = <1>;
+            #size-cells = <0>;
+            interrupts = <GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>;
+            clocks = <&syscon ASPEED_CLK_GATE_REF0CLK>;
+            resets = <&syscon ASPEED_RESET_PECI>;
+            clock-frequency = <24000000>;
+
+            peci-client@30 {
+                compatible = "intel,peci-client";
+                reg = <0x30>;
+            };
+
+            peci-client@31 {
+                compatible = "intel,peci-client";
+                reg = <0x31>;
+            };
+        };
+    };
+...
Signature · 1 line
2.17.1
#11 lore raw

PATCH 11/14 mfd: intel-peci-client: Add Intel PECI client driver

In reply to Jae Hyun Yoo

This commit adds Intel PECI client driver.

---
Changes since v11:
- Fixed to use a define for Intel P6 family.
- Fixed style issues.

Changes since v10:
- Fixed minor style issues.

 drivers/mfd/Kconfig                   |  17 +++
 drivers/mfd/Makefile                  |   1 +
 drivers/mfd/intel-peci-client.c       | 148 ++++++++++++++++++++++++++
 include/linux/mfd/intel-peci-client.h | 119 +++++++++++++++++++++
 4 files changed, 285 insertions(+)
 create mode 100644 drivers/mfd/intel-peci-client.c
 create mode 100644 include/linux/mfd/intel-peci-client.h
drivers/mfd/Kconfig +17 -0
index ae24d3ea68ea..36d85144e485 100644
@@ -632,6 +632,23 @@ config MFD_INTEL_MSIC
 	  Passage) chip. This chip embeds audio, battery, GPIO, etc.
 	  devices used in Intel Medfield platforms.
 
+config MFD_INTEL_PECI_CLIENT
+	tristate "Intel PECI client"
+	depends on (PECI || COMPILE_TEST)
+	select MFD_CORE
+	help
+	  If you say yes to this option, support will be included for the
+	  Intel PECI (Platform Environment Control Interface) client. PECI is a
+	  one-wire bus interface that provides a communication channel from PECI
+	  clients in Intel processors and chipset components to external
+	  monitoring or control devices.
+
+	  Additional drivers must be enabled in order to use the functionality
+	  of the device.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called intel-peci-client.
+
 config MFD_IPAQ_MICRO
 	bool "Atmel Micro ASIC (iPAQ h3100/h3600/h3700) Support"
 	depends on SA1100_H3100 || SA1100_H3600
drivers/mfd/Makefile +1 -0
index c1067ea46204..07722f3d80b6 100644
@@ -212,6 +212,7 @@ obj-$(CONFIG_MFD_INTEL_LPSS)	+= intel-lpss.o
 obj-$(CONFIG_MFD_INTEL_LPSS_PCI)	+= intel-lpss-pci.o
 obj-$(CONFIG_MFD_INTEL_LPSS_ACPI)	+= intel-lpss-acpi.o
 obj-$(CONFIG_MFD_INTEL_MSIC)	+= intel_msic.o
+obj-$(CONFIG_MFD_INTEL_PECI_CLIENT)	+= intel-peci-client.o
 obj-$(CONFIG_MFD_PALMAS)	+= palmas.o
 obj-$(CONFIG_MFD_VIPERBOARD)    += viperboard.o
 obj-$(CONFIG_MFD_RC5T583)	+= rc5t583.o rc5t583-irq.o
drivers/mfd/intel-peci-client.c new file +148 -0

148 lines not on this page · raw message

include/linux/mfd/intel-peci-client.h new file +119 -0

119 lines not on this page · raw message

Signature · 1 line
2.17.1
#12 lore raw

PATCH 12/14 Documentation: hwmon: Add documents for PECI hwmon drivers

In reply to Jae Hyun Yoo

This commit adds hwmon documents for PECI cputemp and dimmtemp drivers.

---
Changes since v11:
- None

Changes since v10:
- Changed documents format to rst.

 Documentation/hwmon/index.rst         |  2 +
 Documentation/hwmon/peci-cputemp.rst  | 95 +++++++++++++++++++++++++++
 Documentation/hwmon/peci-dimmtemp.rst | 60 +++++++++++++++++
 3 files changed, 157 insertions(+)
 create mode 100644 Documentation/hwmon/peci-cputemp.rst
 create mode 100644 Documentation/hwmon/peci-dimmtemp.rst
Documentation/hwmon/index.rst +2 -0
index 230ad59b462b..7d894c9e07ed 100644
@@ -128,6 +128,8 @@ Hardware Monitoring Kernel Drivers
    pc87360
    pc87427
    pcf8591
+   peci-cputemp
+   peci-dimmtemp
    pmbus
    powr1220
    pxe1610
Documentation/hwmon/peci-cputemp.rst new file +95 -0

96 lines not on this page · raw message

Documentation/hwmon/peci-dimmtemp.rst new file +60 -0

60 lines not on this page · raw message

Signature · 1 line
2.17.1
#13 lore raw

PATCH 13/14 hwmon: Add PECI cputemp driver

In reply to Jae Hyun Yoo

This commit adds PECI cputemp hwmon driver.

---
Changes since v11:
- Added LE16 conversion for reading DTS.
- Replaced core temperature label table with dynamic table.
- Fixed style issues.

Changes since v10:
- Added Skylake Xeon D support.
- Added DTS temperature which is more thermal control friendlier than Die temperature.
- Fixed minor bugs and style issues.

 drivers/hwmon/Kconfig        |  14 ++
 drivers/hwmon/Makefile       |   1 +
 drivers/hwmon/peci-cputemp.c | 472 +++++++++++++++++++++++++++++++++++
 drivers/hwmon/peci-hwmon.h   |  48 ++++
 4 files changed, 535 insertions(+)
 create mode 100644 drivers/hwmon/peci-cputemp.c
 create mode 100644 drivers/hwmon/peci-hwmon.h
drivers/hwmon/Kconfig +14 -0
index 13a6b4afb4b3..d1422d9b8055 100644
@@ -1322,6 +1322,20 @@ config SENSORS_PCF8591
 	  These devices are hard to detect and rarely found on mainstream
 	  hardware. If unsure, say N.
 
+config SENSORS_PECI_CPUTEMP
+	tristate "PECI CPU temperature monitoring client"
+	depends on PECI
+	select MFD_INTEL_PECI_CLIENT
+	help
+	  If you say yes here you get support for the generic Intel PECI
+	  cputemp driver which provides Digital Thermal Sensor (DTS) thermal
+	  readings of the CPU package and CPU cores that are accessible using
+	  the PECI Client Command Suite via the processor PECI client.
+	  Check <file:Documentation/hwmon/peci-cputemp.rst> for details.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called peci-cputemp.
+
 source "drivers/hwmon/pmbus/Kconfig"
 
 config SENSORS_PWM_FAN
drivers/hwmon/Makefile +1 -0
index 40c036ea45e6..bab572e5bac0 100644
@@ -141,6 +141,7 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR)	+= ntc_thermistor.o
 obj-$(CONFIG_SENSORS_PC87360)	+= pc87360.o
 obj-$(CONFIG_SENSORS_PC87427)	+= pc87427.o
 obj-$(CONFIG_SENSORS_PCF8591)	+= pcf8591.o
+obj-$(CONFIG_SENSORS_PECI_CPUTEMP)	+= peci-cputemp.o
 obj-$(CONFIG_SENSORS_POWR1220)  += powr1220.o
 obj-$(CONFIG_SENSORS_PWM_FAN)	+= pwm-fan.o
 obj-$(CONFIG_SENSORS_RASPBERRYPI_HWMON)	+= raspberrypi-hwmon.o
drivers/hwmon/peci-cputemp.c new file +472 -0

472 lines not on this page · raw message

drivers/hwmon/peci-hwmon.h new file +48 -0

48 lines not on this page · raw message

Signature · 1 line
2.17.1
#14 lore raw

PATCH 14/14 hwmon: Add PECI dimmtemp driver

In reply to Jae Hyun Yoo

This commit adds PECI dimmtemp hwmon driver.

---
Changes since v11:
- Added supported CPU model checking into probe.
- Replaced DIMM temperature label table with dynamic table.
- Fixed style issues.

Changes since v10:
- Added Skylake Xeon D support.
- Added max and crit properties for temperature threshold checking.
- Fixed minor bugs and style issues.

 drivers/hwmon/Kconfig         |  14 ++
 drivers/hwmon/Makefile        |   1 +
 drivers/hwmon/peci-dimmtemp.c | 425 ++++++++++++++++++++++++++++++++++
 3 files changed, 440 insertions(+)
 create mode 100644 drivers/hwmon/peci-dimmtemp.c
drivers/hwmon/Kconfig +14 -0
index d1422d9b8055..e244a7901392 100644
@@ -1336,6 +1336,20 @@ config SENSORS_PECI_CPUTEMP
 	  This driver can also be built as a module. If so, the module
 	  will be called peci-cputemp.
 
+config SENSORS_PECI_DIMMTEMP
+	tristate "PECI DIMM temperature monitoring client"
+	depends on PECI
+	select MFD_INTEL_PECI_CLIENT
+	help
+	  If you say yes here you get support for the generic Intel PECI hwmon
+	  driver which provides Digital Thermal Sensor (DTS) thermal readings of
+	  DIMM components that are accessible using the PECI Client Command
+	  Suite via the processor PECI client.
+	  Check <file:Documentation/hwmon/peci-dimmtemp.rst> for details.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called peci-dimmtemp.
+
 source "drivers/hwmon/pmbus/Kconfig"
 
 config SENSORS_PWM_FAN
drivers/hwmon/Makefile +1 -0
index bab572e5bac0..1c7ab361adc7 100644
@@ -142,6 +142,7 @@ obj-$(CONFIG_SENSORS_PC87360)	+= pc87360.o
 obj-$(CONFIG_SENSORS_PC87427)	+= pc87427.o
 obj-$(CONFIG_SENSORS_PCF8591)	+= pcf8591.o
 obj-$(CONFIG_SENSORS_PECI_CPUTEMP)	+= peci-cputemp.o
+obj-$(CONFIG_SENSORS_PECI_DIMMTEMP)	+= peci-dimmtemp.o
 obj-$(CONFIG_SENSORS_POWR1220)  += powr1220.o
 obj-$(CONFIG_SENSORS_PWM_FAN)	+= pwm-fan.o
 obj-$(CONFIG_SENSORS_RASPBERRYPI_HWMON)	+= raspberrypi-hwmon.o
drivers/hwmon/peci-dimmtemp.c new file +425 -0

425 lines not on this page · raw message

Signature · 1 line
2.17.1
maintainer
#15 lore raw
In reply to Jae Hyun Yoo
Quoted 4 lines · Jae Hyun Yoo

I'm still trying to upstream it but it would take more time so I'm sending it to OpenBMC list to get cherry picked in the meantime.

Quoted 8 lines

I rebased it on dev-5.4 branch and it includes fixes for addressing upstream review comments I've got so far.

Below change should be removed from the OpenBMC linux tree before applying it to avoid conflicts:

c31349b9039281107b948bf94ed5e53c235c8081 (ARM: dts: aspeed: peci: Add PECI node)

Thanks. I have applied this to dev-5.4. Please test.

Cheers,

Joel

maintainer
#16 lore raw
Quoted 9 lines · Joel Stanley
Quoted 7 lines · Jae Hyun Yoo

I'm still trying to upstream it but it would take more time so I'm sending it to OpenBMC list to get cherry picked in the meantime.

I rebased it on dev-5.4 branch and it includes fixes for addressing upstream review comments I've got so far.

Quoted 7 lines
Quoted 5 lines

Below change should be removed from the OpenBMC linux tree before applying it to avoid conflicts:

c31349b9039281107b948bf94ed5e53c235c8081 (ARM: dts: aspeed: peci: Add PECI node)

Thanks. I have applied this to dev-5.4. Please test.

When CONFIG_OF_DYNAMIC=y we get this build failure:

../drivers/peci/peci-core.c:1717:52: error: passing argument 4 of ‘bus_find_device’ from incompatible pointer type [-Werror=incompatible-pointer-types]

 1717 |  dev = bus_find_device(&peci_bus_type, NULL, node, peci_of_match_node);
      |                                                    ^~~~~~~~~~~~~~~~~~
      |                                                    |
      |                                                    int
(*)(struct device *, void *)
In file included from ../include/linux/node.h:18,
                 from ../include/linux/cpu.h:17,
                 from ../include/linux/of_device.h:5,
                 from ../drivers/peci/peci-core.c:8:

../include/linux/device.h:176:16: note: expected ‘int (*)(struct device *, const void *)’ but argument is of type ‘int (*)(struct device *, void *)’
176 | struct device *bus_find_device(struct bus_type *bus, struct
device *start,

      |                ^~~~~~~~~~~~~~~

../drivers/peci/peci-core.c: In function ‘peci_of_find_adapter’:
../drivers/peci/peci-core.c:1734:52: error: passing argument 4 of ‘bus_find_device’ from incompatible pointer type [-Werror=incompatible-pointer-types]

 1734 |  dev = bus_find_device(&peci_bus_type, NULL, node, peci_of_match_node);
      |                                                    ^~~~~~~~~~~~~~~~~~
      |                                                    |
      |                                                    int
(*)(struct device *, void *)
In file included from ../include/linux/node.h:18,
                 from ../include/linux/cpu.h:17,
                 from ../include/linux/of_device.h:5,
                 from ../drivers/peci/peci-core.c:8:

../include/linux/device.h:176:16: note: expected ‘int (*)(struct device *, const void *)’ but argument is of type ‘int (*)(struct device *, void *)’
176 | struct device *bus_find_device(struct bus_type *bus, struct
device *start,

      |                ^~~~~~~~~~~~~~~

cc1: some warnings being treated as errors

Additioanlly, the nuvoton device trees in dev-5.4 did not compile. I will send a patch for that.

Cheers,

Joel

#17 lore raw

Hi Joel,

Quoted 51 lines · Joel Stanley
Quoted 9 lines · Joel Stanley
Quoted 7 lines · Jae Hyun Yoo

I'm still trying to upstream it but it would take more time so I'm sending it to OpenBMC list to get cherry picked in the meantime.

I rebased it on dev-5.4 branch and it includes fixes for addressing upstream review comments I've got so far.

Quoted 7 lines
Quoted 5 lines

Below change should be removed from the OpenBMC linux tree before applying it to avoid conflicts:

c31349b9039281107b948bf94ed5e53c235c8081 (ARM: dts: aspeed: peci: Add PECI node)

Thanks. I have applied this to dev-5.4. Please test.

When CONFIG_OF_DYNAMIC=y we get this build failure:

../drivers/peci/peci-core.c:1717:52: error: passing argument 4 of ‘bus_find_device’ from incompatible pointer type [-Werror=incompatible-pointer-types]

  1717 |  dev = bus_find_device(&peci_bus_type, NULL, node, peci_of_match_node);
       |                                                    ^~~~~~~~~~~~~~~~~~
       |                                                    |
       |                                                    int
(*)(struct device *, void *)
In file included from ../include/linux/node.h:18,
                  from ../include/linux/cpu.h:17,
                  from ../include/linux/of_device.h:5,
                  from ../drivers/peci/peci-core.c:8:

../include/linux/device.h:176:16: note: expected ‘int (*)(struct device *, const void *)’ but argument is of type ‘int (*)(struct device *, void *)’
176 | struct device *bus_find_device(struct bus_type *bus, struct
device *start,

       |                ^~~~~~~~~~~~~~~

../drivers/peci/peci-core.c: In function ‘peci_of_find_adapter’:
../drivers/peci/peci-core.c:1734:52: error: passing argument 4 of ‘bus_find_device’ from incompatible pointer type [-Werror=incompatible-pointer-types]

  1734 |  dev = bus_find_device(&peci_bus_type, NULL, node, peci_of_match_node);
       |                                                    ^~~~~~~~~~~~~~~~~~
       |                                                    |
       |                                                    int
(*)(struct device *, void *)
In file included from ../include/linux/node.h:18,
                  from ../include/linux/cpu.h:17,
                  from ../include/linux/of_device.h:5,
                  from ../drivers/peci/peci-core.c:8:
Quoted 7 lines

../include/linux/device.h:176:16: note: expected ‘int (*)(struct device *, const void *)’ but argument is of type ‘int (*)(struct device *, void *)’
176 | struct device *bus_find_device(struct bus_type *bus, struct
device *start,

       |                ^~~~~~~~~~~~~~~

cc1: some warnings being treated as errors

I checked that bus_find_device() definition was changed in June so building it using -Werror will treat this warning as an error.

I made a fix and checked that the warning can be resolved. Please apply below fix to patch 03/14 in this series or let me know if you need v2 patch.

Thanks,

Jae

drivers/peci/peci-core.c +1 -1
index 61a2a59a9fe4..9aedb74710e6 100644
@@ -1703,7 +1703,7 @@ static void peci_of_register_devices(struct peci_adapter *adapter) { }
 #endif /* CONFIG_OF */
 
 #if IS_ENABLED(CONFIG_OF_DYNAMIC)
-static int peci_of_match_node(struct device *dev, void *data)
+static int peci_of_match_node(struct device *dev, const void *data)
 {
        return dev->of_node == data;
 }
Quoted 7 lines

Additioanlly, the nuvoton device trees in dev-5.4 did not compile. I will send a patch for that.

Cheers,

Joel