1.. SPDX-License-Identifier: GPL-2.0-or-later
2
3Kernel driver sbrmi
4===================
5
6Supported hardware:
7
8  * Sideband Remote Management Interface (SB-RMI) compliant AMD SoC
9    device connected to the BMC via the APML.
10
11    Prefix: 'sbrmi'
12
13    Addresses scanned: This driver doesn't support address scanning.
14
15    To instantiate this driver on an AMD CPU with SB-RMI
16    support, the i2c bus number would be the bus connected from the board
17    management controller (BMC) to the CPU.
18    The SMBus address is really 7 bits. Some vendors and the SMBus
19    specification show the address as 8 bits, left justified with the R/W
20    bit as a write (0) making bit 0. Some vendors use only the 7 bits
21    to describe the address.
22    As mentioned in AMD's APML specification, The SB-RMI address is
23    normally 78h(0111 100W) or 3Ch(011 1100) for socket 0 and 70h(0111 000W)
24    or 38h(011 1000) for socket 1, but it could vary based on hardware
25    address select pins.
26
27    Datasheet: The SB-RMI interface and protocol along with the Advanced
28               Platform Management Link (APML) Specification is available
29               as part of the open source SoC register reference at:
30
31               https://www.amd.com/en/support/tech-docs?keyword=55898
32
33Author: Akshay Gupta <akshay.gupta@amd.com>
34
35Description
36-----------
37
38The APML provides a way to communicate with the SB Remote Management interface
39(SB-RMI) module from the external SMBus master that can be used to report socket
40power on AMD platforms using mailbox command and resembles a typical 8-pin remote
41power sensor's I2C interface to BMC.
42
43This driver implements current power with power cap and power cap max.
44
45sysfs-Interface
46---------------
47Power sensors can be queried and set via the standard ``hwmon`` interface
48on ``sysfs``, under the directory ``/sys/class/hwmon/hwmonX`` for some value
49of ``X`` (search for the ``X`` such that ``/sys/class/hwmon/hwmonX/name`` has
50content ``sbrmi``)
51
52================ ===== ========================================================
53Name             Perm   Description
54================ ===== ========================================================
55power1_input     RO    Current Power consumed
56power1_cap       RW    Power limit can be set between 0 and power1_cap_max
57power1_cap_max   RO    Maximum powerlimit calculated and reported by the SMU FW
58================ ===== ========================================================
59
60The following example show how the 'Power' attribute from the i2c-addresses
61can be monitored using the userspace utilities like ``sensors`` binary::
62
63  # sensors
64  sbrmi-i2c-1-38
65  Adapter: bcm2835 I2C adapter
66  power1:       61.00 W (cap = 225.00 W)
67
68  sbrmi-i2c-1-3c
69  Adapter: bcm2835 I2C adapter
70  power1:       28.39 W (cap = 224.77 W)
71  #
72
73Also, Below shows how get and set the values from sysfs entries individually::
74  # cat /sys/class/hwmon/hwmon1/power1_cap_max
75  225000000
76
77  # echo 180000000 > /sys/class/hwmon/hwmon1/power1_cap
78  # cat /sys/class/hwmon/hwmon1/power1_cap
79  180000000
80