SCPI sensors support
Subsystems (5)
v4 cover SCPI sensors support
Hi,
This series adds support for SCPI based sensors for ARM development platform. In addition to supporting sensors, when a temperature sensor is discovered the driver registers the sensor with the thermal framework.
The sensor patches here have been split out from a longer series adding support for registering power model based cooling devices for the CPU via device tree. Earliers postings can be seen at [0], [1], [2].
Patches 1-3 create a hwmon sensor driver for sensors provided by SCPI firmware. Patch 4 adds support for the temperature sensors to register with the thermal framework. This allows setting up platform thermals using OF thermal bindings.
The last patch adds support for the sensors in the Juno r0 device tree.
The patches depend on SCPI and mailbox patches[3] from Sudeep. The SCPI protocol document with details of the sensor interface can be found at [4].
I'd like to aim for merging the patches with the SCPI changes if possible. The hwmon patches have been acked by Guenter. If there aren't any objections, I would like to request acks for the binding updates in Patch 1.
Thanks,
Punit
Changes v3 -> v4
- clarified binding regarding use of sensor identifier
Changes v2 -> v3
- split out the sensor patches (posted here)
- rebase onto v4.3-rc1
Changes v1 -> v2
- added documentation for the scpi-hwmon driver
- replaced static allocation of platform structure in scpi-hwmon.c with dynamic allocation
- re-structured registering of thermal zones to better handle error conditions
- reduced chattiness in scpi-hwmon.c
- corrected sensor numbering to align with hwmon documentation
- dynamic allocation of attributes and attribute groups
[0] http://thread.gmane.org/gmane.linux.kernel/2002152
[1] http://thread.gmane.org/gmane.linux.kernel/2011466
[2] http://thread.gmane.org/gmane.linux.power-management.general/65475
[3] http://thread.gmane.org/gmane.linux.kernel/2009735
[4] http://infocenter.arm.com/help/topic/com.arm.doc.dui0922b/index.html
Punit Agrawal (5):
Documentation: add DT bindings for ARM SCPI sensors
firmware: arm_scpi: Extend to support sensors
hwmon: Support sensors exported via ARM SCP interface
hwmon: Support thermal zones registration for SCP temperature sensors
arm64: dts: Add sensor node to Juno dt
Documentation/devicetree/bindings/arm/arm,scpi.txt | 38 +++ Documentation/hwmon/scpi-hwmon | 33 +++ arch/arm64/boot/dts/arm/juno-base.dtsi | 5 + drivers/firmware/arm_scpi.c | 60 +++++ drivers/hwmon/Kconfig | 8 + drivers/hwmon/Makefile | 1 + drivers/hwmon/scpi-hwmon.c | 288 +++++++++++++++++++++ include/linux/scpi_protocol.h | 17 ++ 8 files changed, 450 insertions(+) create mode 100644 Documentation/hwmon/scpi-hwmon create mode 100644 drivers/hwmon/scpi-hwmon.c
Signature · 1 line
2.5.1
PATCH v4 1/5 Documentation: add DT bindings for ARM SCPI sensors
The System Control Processor (SCP) provides access to SoC sensors via the System Control and Power Interface (SCPI) Message Protocol. Add bindings to allow probing of these sensors. Also support referencing of the sensors for setting up thermal zones via the thermal DT bindings.
--- Documentation/devicetree/bindings/arm/arm,scpi.txt | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+)
Documentation/devicetree/bindings/arm/arm,scpi.txt +38 -0
@@ -72,8 +72,25 @@ Required sub-node properties: - compatible : should be "arm,juno-scp-shmem" for Non-secure SRAM based shared memory on Juno platforms +Sensor bindings for the sensors based on SCPI Message Protocol +-------------------------------------------------------------- +SCPI provides an API to access the various sensors on the SoC. + +Required properties: +- compatible : should be "arm,scpi-sensors". +- #thermal-sensor-cells: should be set to 1. This property follows the + thermal device tree bindings[2]. + + Valid cell values are raw identifiers (Sensor + ID) as used by the firmware. Refer to + platform documentation for your + implementation for the IDs to use. For Juno + R0 and Juno R1 refer to [3]. + [0] http://infocenter.arm.com/help/topic/com.arm.doc.dui0922b/index.html [1] Documentation/devicetree/bindings/clock/clock-bindings.txt +[2] Documentation/devicetree/bindings/thermal/thermal.txt +[3] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0922b/apas03s22.html Example:
@@ -122,6 +139,11 @@ scpi_protocol: scpi at 2e000000 { clock-output-names = "pxlclk0", "pxlclk1"; }; }; + + scpi_sensors0: sensors { + compatible = "arm,scpi-sensors"; + #thermal-sensor-cells = <1>; + }; }; cpu at 0 {
@@ -136,6 +158,17 @@ hdlcd at 7ff60000 { clocks = <&scpi_clk 4>; }; +thermal-zones { + soc_thermal { + polling-delay-passive = <100>; + polling-delay = <1000>; + + /* sensor ID */ + thermal-sensors = <&scpi_sensors0 3>; + ... + }; +}; + In the above example, the #clock-cells is set to 1 as required. scpi_dvfs has 3 output clocks namely: atlclk, aplclk, and gpuclk with 0, 1 and 2 as clock-indices. scpi_clk has 2 output clocks namely: pxlclk0
@@ -148,3 +181,8 @@ scpi_dvfs i.e. "atlclk". Similarly the second example is hdlcd at 7ff60000 and it has pxlclk1 as input clock. '4' in the clock specifier here points to the second entry in the output clocks of scpi_clocks i.e. "pxlclk1" + +The thermal-sensors property in the soc_thermal node uses the +temperature sensor provided by SCP firmware to setup a thermal +zone. The ID "3" is the sensor identifier for the temperature sensor +as used by the firmware.
Signature · 1 line
2.5.1
Re: [PATCH v4 1/5] Documentation: add DT bindings for ARM SCPI sensors
Quoted 10 lines · Punit Agrawal
The System Control Processor (SCP) provides access to SoC sensors via the System Control and Power Interface (SCPI) Message Protocol. Add bindings to allow probing of these sensors. Also support referencing of the sensors for setting up thermal zones via the thermal DT bindings.
Signed-off-by Punit Agrawal <[email protected]>Cc Rob Herring <[email protected]>Cc Mark Rutland <[email protected]>Cc Sudeep Holla <[email protected]>
Gentle reminder for review of the below bindings. They've been updated based on feedback on the earlier version [a].
If there are no further comments, I'd like to request an ack from the DT reviewers.
[a] http://thread.gmane.org/gmane.linux.power-management.general/65475/focus=134976
Quoted 73 lines
--- Documentation/devicetree/bindings/arm/arm,scpi.txt | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+)Documentation/devicetree/bindings/arm/arm,scpi.txt +38
-0@@ -72,8 +72,25 @@ Required sub-node properties: - compatible : should be "arm,juno-scp-shmem" for Non-secure SRAM based shared memory on Juno platforms +Sensor bindings for the sensors based on SCPI Message Protocol +-------------------------------------------------------------- +SCPI provides an API to access the various sensors on the SoC. + +Required properties: +- compatible : should be "arm,scpi-sensors". +- #thermal-sensor-cells: should be set to 1. This property follows the + thermal device tree bindings[2]. + + Valid cell values are raw identifiers (Sensor + ID) as used by the firmware. Refer to + platform documentation for your + implementation for the IDs to use. For Juno + R0 and Juno R1 refer to [3]. + [0] http://infocenter.arm.com/help/topic/com.arm.doc.dui0922b/index.html [1] Documentation/devicetree/bindings/clock/clock-bindings.txt +[2] Documentation/devicetree/bindings/thermal/thermal.txt +[3] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0922b/apas03s22.html Example:@@ -122,6 +139,11 @@ scpi_protocol: scpi at 2e000000 { clock-output-names = "pxlclk0", "pxlclk1"; }; }; + + scpi_sensors0: sensors { + compatible = "arm,scpi-sensors"; + #thermal-sensor-cells = <1>; + }; }; cpu at 0 {@@ -136,6 +158,17 @@ hdlcd at 7ff60000 { clocks = <&scpi_clk 4>; }; +thermal-zones { + soc_thermal { + polling-delay-passive = <100>; + polling-delay = <1000>; + + /* sensor ID */ + thermal-sensors = <&scpi_sensors0 3>; + ... + }; +}; + In the above example, the #clock-cells is set to 1 as required. scpi_dvfs has 3 output clocks namely: atlclk, aplclk, and gpuclk with 0, 1 and 2 as clock-indices. scpi_clk has 2 output clocks namely: pxlclk0@@ -148,3 +181,8 @@ scpi_dvfs i.e. "atlclk". Similarly the second example is hdlcd at 7ff60000 and it has pxlclk1 as input clock. '4' in the clock specifier here points to the second entry in the output clocks of scpi_clocks i.e. "pxlclk1" + +The thermal-sensors property in the soc_thermal node uses the +temperature sensor provided by SCP firmware to setup a thermal +zone. The ID "3" is the sensor identifier for the temperature sensor +as used by the firmware.
Re: [PATCH v4 1/5] Documentation: add DT bindings for ARM SCPI sensors
Quoted 13 lines · Punit Agrawal
Quoted 10 lines · Punit Agrawal
The System Control Processor (SCP) provides access to SoC sensors via the System Control and Power Interface (SCPI) Message Protocol. Add bindings to allow probing of these sensors. Also support referencing of the sensors for setting up thermal zones via the thermal DT bindings.
Signed-off-by Punit Agrawal <[email protected]>Cc Rob Herring <[email protected]>Cc Mark Rutland <[email protected]>Cc Sudeep Holla <[email protected]>
Quoted 5 lines
Gentle reminder for review of the below bindings. They've been updated based on feedback on the earlier version [a].
If there are no further comments, I'd like to request an ack from the DT reviewers.
Ping!
Quoted 80 lines
[a] http://thread.gmane.org/gmane.linux.power-management.general/65475/focus=134976
Quoted 65 lines
--- Documentation/devicetree/bindings/arm/arm,scpi.txt | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+)Documentation/devicetree/bindings/arm/arm,scpi.txt +33
-0@@ -72,8 +72,25 @@ Required sub-node properties: - compatible : should be "arm,juno-scp-shmem" for Non-secure SRAM based shared memory on Juno platforms +Sensor bindings for the sensors based on SCPI Message Protocol +-------------------------------------------------------------- +SCPI provides an API to access the various sensors on the SoC. + +Required properties: +- compatible : should be "arm,scpi-sensors". +- #thermal-sensor-cells: should be set to 1. This property follows the + thermal device tree bindings[2]. + + Valid cell values are raw identifiers (Sensor + ID) as used by the firmware. Refer to + platform documentation for your + implementation for the IDs to use. For Juno + R0 and Juno R1 refer to [3]. + [0] http://infocenter.arm.com/help/topic/com.arm.doc.dui0922b/index.html [1] Documentation/devicetree/bindings/clock/clock-bindings.txt +[2] Documentation/devicetree/bindings/thermal/thermal.txt +[3] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0922b/apas03s22.html Example:@@ -122,6 +139,11 @@ scpi_protocol: scpi at 2e000000 { clock-output-names = "pxlclk0", "pxlclk1"; }; }; + + scpi_sensors0: sensors { + compatible = "arm,scpi-sensors"; + #thermal-sensor-cells = <1>; + }; }; cpu at 0 {@@ -136,6 +158,17 @@ hdlcd at 7ff60000 { clocks = <&scpi_clk 4>; }; +thermal-zones { + soc_thermal { + polling-delay-passive = <100>; + polling-delay = <1000>; + + /* sensor ID */ + thermal-sensors = <&scpi_sensors0 3>; + ... + }; +}; + In the above example, the #clock-cells is set to 1 as required. scpi_dvfs has 3 output clocks namely: atlclk, aplclk, and gpuclk with 0, 1 and 2 as clock-indices. scpi_clk has 2 output clocks namely: pxlclk0Documentation/devicetree/bindings/arm/arm,scpi.txt scpi_dvfs i.e. "atlclk". · line 188
Quoted 8 lines
Documentation/devicetree/bindings/arm/arm,scpi.txt +5
-0@@ -148,3 +181,8 @@ scpi_dvfs i.e. "atlclk". Similarly the second example is hdlcd at 7ff60000 and it has pxlclk1 as input clock. '4' in the clock specifier here points to the second entry in the output clocks of scpi_clocks i.e. "pxlclk1" + +The thermal-sensors property in the soc_thermal node uses the +temperature sensor provided by SCP firmware to setup a thermal +zone. The ID "3" is the sensor identifier for the temperature sensor +as used by the firmware.--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 1/5] Documentation: add DT bindings for ARM SCPI sensors
In reply to Punit AgrawalQuoted 8 lines · Punit Agrawal
The System Control Processor (SCP) provides access to SoC sensors via the System Control and Power Interface (SCPI) Message Protocol. Add bindings to allow probing of these sensors. Also support referencing of the sensors for setting up thermal zones via the thermal DT bindings.
Signed-off-by Punit Agrawal <[email protected]>Cc Rob Herring <[email protected]>
Quoted 78 lines
Cc Mark Rutland <[email protected]>Cc Sudeep Holla <[email protected]>--- Documentation/devicetree/bindings/arm/arm,scpi.txt | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+)Documentation/devicetree/bindings/arm/arm,scpi.txt +38
-1@@ -72,8 +72,25 @@ Required sub-node properties: - compatible : should be "arm,juno-scp-shmem" for Non-secure SRAM based shared memory on Juno platforms +Sensor bindings for the sensors based on SCPI Message Protocol +-------------------------------------------------------------- +SCPI provides an API to access the various sensors on the SoC. + +Required properties: +- compatible : should be "arm,scpi-sensors". +- #thermal-sensor-cells: should be set to 1. This property follows the + thermal device tree bindings[2]. + + Valid cell values are raw identifiers (Sensor + ID) as used by the firmware. Refer to + platform documentation for your + implementation for the IDs to use. For Juno + R0 and Juno R1 refer to [3]. + [0] http://infocenter.arm.com/help/topic/com.arm.doc.dui0922b/index.html [1] Documentation/devicetree/bindings/clock/clock-bindings.txt +[2] Documentation/devicetree/bindings/thermal/thermal.txt +[3] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0922b/apas03s22.html Example:@@ -122,6 +139,11 @@ scpi_protocol: scpi at 2e000000 { clock-output-names = "pxlclk0", "pxlclk1"; }; }; + + scpi_sensors0: sensors { + compatible = "arm,scpi-sensors"; + #thermal-sensor-cells = <1>; + }; }; cpu at 0 {@@ -136,6 +158,17 @@ hdlcd at 7ff60000 { clocks = <&scpi_clk 4>; }; +thermal-zones { + soc_thermal { + polling-delay-passive = <100>; + polling-delay = <1000>; + + /* sensor ID */ + thermal-sensors = <&scpi_sensors0 3>; + ... + }; +}; + In the above example, the #clock-cells is set to 1 as required. scpi_dvfs has 3 output clocks namely: atlclk, aplclk, and gpuclk with 0, 1 and 2 as clock-indices. scpi_clk has 2 output clocks namely: pxlclk0@@ -148,3 +181,8 @@ scpi_dvfs i.e. "atlclk". Similarly the second example is hdlcd at 7ff60000 and it has pxlclk1 as input clock. '4' in the clock specifier here points to the second entry in the output clocks of scpi_clocks i.e. "pxlclk1" + +The thermal-sensors property in the soc_thermal node uses the +temperature sensor provided by SCP firmware to setup a thermal +zone. The ID "3" is the sensor identifier for the temperature sensor +as used by the firmware. --2.5.1
Re: [PATCH v4 1/5] Documentation: add DT bindings for ARM SCPI sensors
Quoted 11 lines · Rob Herring
Quoted 8 lines · Punit Agrawal
The System Control Processor (SCP) provides access to SoC sensors via the System Control and Power Interface (SCPI) Message Protocol. Add bindings to allow probing of these sensors. Also support referencing of the sensors for setting up thermal zones via the thermal DT bindings.
Signed-off-by Punit Agrawal <[email protected]>Cc Rob Herring <[email protected]>Acked-by Rob Herring <[email protected]>
Thanks, Rob!
Sudeep, now that we have acks for all the patches, are you OK to take this patchset along with your series adding support for SCPI?
Punit
Quoted 83 lines
Quoted 77 lines
Cc Mark Rutland <[email protected]>Cc Sudeep Holla <[email protected]>--- Documentation/devicetree/bindings/arm/arm,scpi.txt | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+)Documentation/devicetree/bindings/arm/arm,scpi.txt +38
-1@@ -72,8 +72,25 @@ Required sub-node properties: - compatible : should be "arm,juno-scp-shmem" for Non-secure SRAM based shared memory on Juno platforms +Sensor bindings for the sensors based on SCPI Message Protocol +-------------------------------------------------------------- +SCPI provides an API to access the various sensors on the SoC. + +Required properties: +- compatible : should be "arm,scpi-sensors". +- #thermal-sensor-cells: should be set to 1. This property follows the + thermal device tree bindings[2]. + + Valid cell values are raw identifiers (Sensor + ID) as used by the firmware. Refer to + platform documentation for your + implementation for the IDs to use. For Juno + R0 and Juno R1 refer to [3]. + [0] http://infocenter.arm.com/help/topic/com.arm.doc.dui0922b/index.html [1] Documentation/devicetree/bindings/clock/clock-bindings.txt +[2] Documentation/devicetree/bindings/thermal/thermal.txt +[3] http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0922b/apas03s22.html Example:@@ -122,6 +139,11 @@ scpi_protocol: scpi at 2e000000 { clock-output-names = "pxlclk0", "pxlclk1"; }; }; + + scpi_sensors0: sensors { + compatible = "arm,scpi-sensors"; + #thermal-sensor-cells = <1>; + }; }; cpu at 0 {@@ -136,6 +158,17 @@ hdlcd at 7ff60000 { clocks = <&scpi_clk 4>; }; +thermal-zones { + soc_thermal { + polling-delay-passive = <100>; + polling-delay = <1000>; + + /* sensor ID */ + thermal-sensors = <&scpi_sensors0 3>; + ... + }; +}; + In the above example, the #clock-cells is set to 1 as required. scpi_dvfs has 3 output clocks namely: atlclk, aplclk, and gpuclk with 0, 1 and 2 as clock-indices. scpi_clk has 2 output clocks namely: pxlclk0@@ -148,3 +181,8 @@ scpi_dvfs i.e. "atlclk". Similarly the second example is hdlcd at 7ff60000 and it has pxlclk1 as input clock. '4' in the clock specifier here points to the second entry in the output clocks of scpi_clocks i.e. "pxlclk1" + +The thermal-sensors property in the soc_thermal node uses the +temperature sensor provided by SCP firmware to setup a thermal +zone. The ID "3" is the sensor identifier for the temperature sensor +as used by the firmware. --Quoted 2 lines
2.5.1
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 2/5 firmware: arm_scpi: Extend to support sensors
In reply to Punit AgrawalARM System Control Processor (SCP) provides an API to query and use the sensors available in the system. Extend the SCPI driver to support
sensor messages.
--- drivers/firmware/arm_scpi.c | 60 +++++++++++++++++++++++++++++++++++++++++++ include/linux/scpi_protocol.h | 17 ++++++++++++ 2 files changed, 77 insertions(+)
drivers/firmware/arm_scpi.c +60 -0
@@ -219,6 +219,21 @@ struct dvfs_set {u8 index; } __packed; +struct sensor_capabilities { +__le16 sensors; +} __packed; + +struct _scpi_sensor_info { +__le16 sensor_id; +u8 class; +u8 trigger_type; +char name[20 ]; +}; + +struct sensor_value { +__le32 val; +} __packed; +static struct scpi_drvinfo *scpi_info;static int scpi_linux_errmap[SCPI_ERR_MAX ] = {
@@ -481,6 +496,48 @@ static struct scpi_dvfs_info *scpi_dvfs_get_info(u8 domain)return info; } +static int scpi_sensor_get_capability (u16 *sensors) +{ +struct sensor_capabilities cap_buf; +int ret; + + ret =scpi_send_message (SCPI_CMD_SENSOR_CAPABILITIES ,NULL ,0 , &cap_buf, +sizeof (cap_buf)); +if (!ret) + *sensors =le16_to_cpu (cap_buf.sensors); + +return ret; +} + +static int scpi_sensor_get_info (u16 sensor_id,struct scpi_sensor_info *info) +{ +__le16 id =cpu_to_le16 (sensor_id); +struct _scpi_sensor_info _info; +int ret; + + ret =scpi_send_message (SCPI_CMD_SENSOR_INFO , &id, +sizeof (id), &_info,sizeof (_info)); +if (!ret) { +memcpy (info, &_info,sizeof (*info)); + info->sensor_id =le16_to_cpu (_info.sensor_id); + } + +return ret; +} + +int scpi_sensor_get_value (u16 sensor,u32 *val) +{ +struct sensor_value buf; +int ret; + + ret =scpi_send_message (SCPI_CMD_SENSOR_VALUE , &sensor,sizeof (sensor), + &buf,sizeof (buf)); +if (!ret) + *val =le32_to_cpu (buf.val); + +return ret; +} +static struct scpi_ops scpi_ops = { .get_version = scpi_get_version, .clk_get_range = scpi_clk_get_range,
@@ -489,6 +546,9 @@ static struct scpi_ops scpi_ops = { .dvfs_get_idx = scpi_dvfs_get_idx, .dvfs_set_idx = scpi_dvfs_set_idx, .dvfs_get_info = scpi_dvfs_get_info, + .sensor_get_capability = scpi_sensor_get_capability, + .sensor_get_info = scpi_sensor_get_info, + .sensor_get_value = scpi_sensor_get_value, };struct scpi_ops *get_scpi_ops (void )
include/linux/scpi_protocol.h +17 -0
@@ -28,6 +28,20 @@ struct scpi_dvfs_info {struct scpi_opp *opps; }; +enum scpi_sensor_class { +TEMPERATURE , +VOLTAGE , +CURRENT , +POWER , +}; + +struct scpi_sensor_info { +u16 sensor_id; +u8 class; +u8 trigger_type; +char name[20 ]; +} __packed; +/** * struct scpi_ops - represents the various operations provided * by SCP through SCPI message protocol
@@ -52,6 +66,9 @@ struct scpi_ops {int (*dvfs_get_idx)(u8 );int (*dvfs_set_idx)(u8 ,u8 );struct scpi_dvfs_info *(*dvfs_get_info)(u8 ); +int (*sensor_get_capability)(u16 *sensors); +int (*sensor_get_info)(u16 sensor_id,struct scpi_sensor_info *); +int (*sensor_get_value)(u16 ,u32 *); };#if IS_ENABLED (CONFIG_ARM_SCPI_PROTOCOL )
Signature · 1 line
2.5.1
Re: [PATCH v4 2/5] firmware: arm_scpi: Extend to support sensors
Quoted 6 lines · Punit Agrawal
ARM System Control Processor (SCP) provides an API to query and use the sensors available in the system. Extend the SCPI driver to support
sensor messages.Signed-off-by Punit Agrawal <[email protected]>Cc Sudeep Holla <[email protected]>
Re: [PATCH v4 2/5] firmware: arm_scpi: Extend to support sensors
Quoted 9 lines · Sudeep Holla
Quoted 6 lines · Punit Agrawal
ARM System Control Processor (SCP) provides an API to query and use the sensors available in the system. Extend the SCPI driver to support
sensor messages.Signed-off-by Punit Agrawal <[email protected]>Cc Sudeep Holla <[email protected]>Acked-by Sudeep Holla <[email protected]>
Thanks, Sudeep!
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 3/5 hwmon: Support sensors exported via ARM SCP interface
In reply to Punit AgrawalCreate a driver to add support for SoC sensors exported by the System Control Processor (SCP) via the System Control and Power Interface (SCPI). The supported sensor types is one of voltage, temperature, current, and power.
The sensor labels and values provided by the SCP are exported via the hwmon sysfs interface.
--- Documentation/hwmon/scpi-hwmon | 33 ++++++++ drivers/hwmon/Kconfig | 8 ++ drivers/hwmon/Makefile | 1 + drivers/hwmon/scpi-hwmon.c | 186 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 228 insertions(+) create mode 100644 Documentation/hwmon/scpi-hwmon create mode 100644 drivers/hwmon/scpi-hwmon.c
Documentation/hwmon/scpi-hwmon new file +33 -0
@@ -0,0 +1,33 @@ +Kernel driver scpi-hwmon +======================== + +Supported chips: + * Chips based on ARM System Control Processor Interface + Addresses scanned: - + Datasheet: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0922b/index.html + +Author: Punit Agrawal <[email protected]> + +Description +----------- + +This driver supports hardware monitoring for SoC's based on the ARM +System Control Processor (SCP) implementing the System Control +Processor Interface (SCPI). The following sensor types are supported +by the SCP - + + * temperature + * voltage + * current + * power + +The SCP interface provides an API to query the available sensors and +their values which are then exported to userspace by this driver. + +Usage Notes +----------- + +The driver relies on device tree node to indicate the presence of SCPI +support in the kernel. See +Documentation/devicetree/bindings/arm/arm,scpi.txt for details of the +devicetree node.
drivers/hwmon/Kconfig +8 -0
@@ -1551,6 +1551,14 @@ config SENSORS_VEXPRESS the ARM Ltd's Versatile Express platform. It can provide wide range of information like temperature, power, energy. +config SENSORS_ARM_SCPI + tristate "ARM SCPI Sensors" + depends on ARM_SCPI_PROTOCOL + help + This driver provides support for temperature, voltage, current + and power sensors available on ARM Ltd's SCP based platforms. The + actual number and type of sensors exported depend the platform. + config SENSORS_VIA_CPUTEMP tristate "VIA CPU temperature sensor" depends on X86
drivers/hwmon/Makefile +1 -0
@@ -150,6 +150,7 @@ obj-$(CONFIG_SENSORS_TMP421) += tmp421.o obj-$(CONFIG_SENSORS_TWL4030_MADC)+= twl4030-madc-hwmon.o obj-$(CONFIG_SENSORS_V2M_JUNO) += v2m-juno.o obj-$(CONFIG_SENSORS_VEXPRESS) += vexpress.o +obj-$(CONFIG_SENSORS_ARM_SCPI) += scpi-hwmon.o obj-$(CONFIG_SENSORS_VIA_CPUTEMP)+= via-cputemp.o obj-$(CONFIG_SENSORS_VIA686A) += via686a.o obj-$(CONFIG_SENSORS_VT1211) += vt1211.o
drivers/hwmon/scpi-hwmon.c new file +186 -0
186 lines not on this page · raw message
Signature · 1 line
2.5.1
PATCH v4 4/5 hwmon: Support thermal zones registration for SCP temperature sensors
In reply to Punit AgrawalAdd support to create thermal zones based on the temperature sensors provided by the SCP. The thermal zones can be defined using the thermal DT bindings and should refer to the SCP sensor id to select the sensor.
--- drivers/hwmon/scpi-hwmon.c | 104 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 103 insertions(+), 1 deletion(-)
drivers/hwmon/scpi-hwmon.c +103 -1
@@ -20,6 +20,7 @@#include <linux/scpi_protocol.h> #include <linux/slab.h> #include <linux/sysfs.h> +#include <linux/thermal.h> struct sensor_data {struct scpi_sensor_info info;
@@ -29,14 +30,39 @@ struct sensor_data {char label[20 ]; }; +struct scpi_thermal_zone { +struct list_head list; +int sensor_id; +struct scpi_sensors *scpi_sensors; +struct thermal_zone_device *tzd; +}; +struct scpi_sensors {struct scpi_ops *scpi_ops;struct sensor_data *data; +struct list_head thermal_zones;struct attribute **attrs;struct attribute_group group;const struct attribute_group *groups[2 ]; }; +static int scpi_read_temp (void *dev,int *temp) +{ +struct scpi_thermal_zone *zone = dev; +struct scpi_sensors *scpi_sensors = zone->scpi_sensors; +struct scpi_ops *scpi_ops = scpi_sensors->scpi_ops; +struct sensor_data *sensor = &scpi_sensors->data[zone->sensor_id]; +u32 value; +int ret; + + ret = scpi_ops->sensor_get_value (sensor->info.sensor_id, &value); +if (ret) +return ret; + + *temp = value; +return 0 ; +} +/* hwmon callback functions */ static ssize_t scpi_show_sensor (struct device *dev,struct device_attribute *attr,char *buf)
@@ -66,6 +92,24 @@ scpi_show_label(struct device *dev, struct device_attribute *attr, char *buf)return sprintf (buf,"%s\n" , sensor->info.name); } +static void +unregister_thermal_zones (struct platform_device *pdev, +struct scpi_sensors *scpi_sensors) +{ +struct list_head *pos; + +list_for_each (pos, &scpi_sensors->thermal_zones) { +struct scpi_thermal_zone *zone; + + zone = list_entry(pos, struct scpi_thermal_zone, list); +thermal_zone_of_sensor_unregister (&pdev->dev, zone->tzd); + } +} + +static struct thermal_zone_of_device_ops scpi_sensor_ops = { + .get_temp = scpi_read_temp, +}; +static int scpi_hwmon_probe (struct platform_device *pdev) {u16 nr_sensors, i;
@@ -160,10 +204,67 @@ static int scpi_hwmon_probe(struct platform_device *pdev) scpi_sensors->group.attrs = scpi_sensors->attrs; scpi_sensors->groups[0 ] = &scpi_sensors->group; +platform_set_drvdata (pdev, scpi_sensors); + hwdev =devm_hwmon_device_register_with_groups (dev,"scpi_sensors" , scpi_sensors, scpi_sensors->groups); -return PTR_ERR_OR_ZERO (hwdev); +if (IS_ERR (hwdev)) +return PTR_ERR (hwdev); + +/* +* Register the temperature sensors with the thermal framework +* to allow their usage in setting up the thermal zones from +* device tree. +* +* NOTE: Not all temperature sensors maybe used for thermal +* control +*/ +INIT_LIST_HEAD (&scpi_sensors->thermal_zones); +for (i =0 ; i < nr_sensors; i++) { +struct sensor_data *sensor = &scpi_sensors->data[i]; +struct scpi_thermal_zone *zone; + +if (sensor->info.class !=TEMPERATURE ) +continue ; + + zone =devm_kzalloc (dev,sizeof (*zone),GFP_KERNEL ); +if (!zone) { + ret = -ENOMEM ; + goto unregister_tzd; + } + + zone->sensor_id = i; + zone->scpi_sensors = scpi_sensors; + zone->tzd =thermal_zone_of_sensor_register (dev, i, zone, + &scpi_sensor_ops); +/* +* The call to thermal_zone_of_sensor_register returns +* an error for sensors that are not associated with +* any thermal zones or if the thermal subsystem is +* not configured. +*/ +if (IS_ERR (zone->tzd)) { +devm_kfree (dev, zone); +continue ; + } +list_add (&zone->list, &scpi_sensors->thermal_zones); + } + +return 0 ; + +unregister_tzd: +unregister_thermal_zones (pdev, scpi_sensors); +return ret; +} + +static int scpi_hwmon_remove (struct platform_device *pdev) +{ +struct scpi_sensors *scpi_sensors =platform_get_drvdata (pdev); + +unregister_thermal_zones (pdev, scpi_sensors); + +return 0 ; }static const struct of_device_id scpi_of_match[] = {
@@ -178,6 +279,7 @@ static struct platform_driver scpi_hwmon_platdrv = { .of_match_table = scpi_of_match, }, .probe = scpi_hwmon_probe, + .remove = scpi_hwmon_remove, };module_platform_driver (scpi_hwmon_platdrv);
Signature · 1 line
2.5.1
PATCH v4 5/5 arm64: dts: Add sensor node to Juno dt
In reply to Punit AgrawalThe SCP firmware on Juno provides access to SoC sensors via the SCPI. Add the sensor nodes to the device tree to enable this support.
--- arch/arm64/boot/dts/arm/juno-base.dtsi | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm64/boot/dts/arm/juno-base.dtsi +5 -0
@@ -96,6 +96,11 @@ clock-output-names = "pxlclk0", "pxlclk1"; }; }; + + scpi_sensors0: sensors { + compatible = "arm,scpi-sensors"; + #thermal-sensor-cells = <1>; + }; }; /include/ "juno-clocks.dtsi"
Signature · 1 line
2.5.1
Re: [PATCH v4 5/5] arm64: dts: Add sensor node to Juno dt
Quoted 7 lines · Punit Agrawal
The SCP firmware on Juno provides access to SoC sensors via the SCPI. Add the sensor nodes to the device tree to enable this support.
Signed-off-by Punit Agrawal <[email protected]>Cc Rob Herring <[email protected]>Cc Mark Rutland <[email protected]>Cc Liviu Dudau <[email protected]>
Quoted 24 lines
Cc Sudeep Holla <[email protected]>--- arch/arm64/boot/dts/arm/juno-base.dtsi | 5 +++++ 1 file changed, 5 insertions(+)arch/arm64/boot/dts/arm/juno-base.dtsi +5
-0@@ -96,6 +96,11 @@ clock-output-names = "pxlclk0", "pxlclk1"; }; }; + + scpi_sensors0: sensors { + compatible = "arm,scpi-sensors"; + #thermal-sensor-cells = <1>; + }; }; /include/ "juno-clocks.dtsi"Signature · 1 line
2.5.1
Signature · 8 lines
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
?\_(?)_/?Re: [PATCH v4 5/5] arm64: dts: Add sensor node to Juno dt
Quoted 10 lines · Liviu Dudau
Quoted 7 lines · Punit Agrawal
The SCP firmware on Juno provides access to SoC sensors via the SCPI. Add the sensor nodes to the device tree to enable this support.
Signed-off-by Punit Agrawal <[email protected]>Cc Rob Herring <[email protected]>Cc Mark Rutland <[email protected]>Cc Liviu Dudau <[email protected]>Acked-by Liviu Dudau <[email protected]>
Thanks Liviu!
Quoted 25 lines
Quoted 25 lines
Cc Sudeep Holla <[email protected]>--- arch/arm64/boot/dts/arm/juno-base.dtsi | 5 +++++ 1 file changed, 5 insertions(+)arch/arm64/boot/dts/arm/juno-base.dtsi +5
-0@@ -96,6 +96,11 @@ clock-output-names = "pxlclk0", "pxlclk1"; }; }; + + scpi_sensors0: sensors { + compatible = "arm,scpi-sensors"; + #thermal-sensor-cells = <1>; + }; }; /include/ "juno-clocks.dtsi"Signature · 1 line
2.5.1