From: Punit Agrawal <punit.agrawal@arm.com>
To: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, mark.rutland@arm.com,
robh+dt@kernel.org, edubezval@gmail.com, sudeep.holla@arm.com,
liviu.dudau@arm.com, linux@roeck-us.net,
Punit Agrawal <punit.agrawal@arm.com>
Subject: [PATCH v4 2/5] firmware: arm_scpi: Extend to support sensors
Date: Tue, 15 Sep 2015 17:50:58 +0100 [thread overview]
Message-ID: <1442335861-7282-3-git-send-email-punit.agrawal@arm.com> (raw)
In-Reply-To: <1442335861-7282-1-git-send-email-punit.agrawal@arm.com>
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 <punit.agrawal@arm.com>
Cc: Sudeep Holla <sudeep.holla@arm.com>
---
drivers/firmware/arm_scpi.c | 60 +++++++++++++++++++++++++++++++++++++++++++
include/linux/scpi_protocol.h | 17 ++++++++++++
2 files changed, 77 insertions(+)
diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c
index cb75c75..321680e 100644
--- a/drivers/firmware/arm_scpi.c
+++ b/drivers/firmware/arm_scpi.c
@@ -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)
diff --git a/include/linux/scpi_protocol.h b/include/linux/scpi_protocol.h
index e7169cd..80af3cd 100644
--- a/include/linux/scpi_protocol.h
+++ b/include/linux/scpi_protocol.h
@@ -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)
--
2.5.1
next prev parent reply other threads:[~2015-09-15 16:50 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-15 16:50 [PATCH v4 0/5] SCPI sensors support Punit Agrawal
2015-09-15 16:50 ` [PATCH v4 1/5] Documentation: add DT bindings for ARM SCPI sensors Punit Agrawal
2015-09-22 14:31 ` Punit Agrawal
[not found] ` <9hhoagubk4m.fsf-Z9gB6HwUD+TZROr8t4l/smS4ubULX0JqMm0uRHvK7Nw@public.gmane.org>
2015-09-29 15:11 ` Punit Agrawal
[not found] ` <1442335861-7282-2-git-send-email-punit.agrawal-5wv7dgnIgG8@public.gmane.org>
2015-09-29 18:20 ` Rob Herring
[not found] ` <CAL_Jsq+_Rrv5XqNsL-gwQZv3HK20dQC3jY7qCoxQ8KWhhs4Fdw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-09-30 8:57 ` Punit Agrawal
2015-09-15 16:50 ` Punit Agrawal [this message]
[not found] ` <1442335861-7282-3-git-send-email-punit.agrawal-5wv7dgnIgG8@public.gmane.org>
2015-10-02 16:36 ` [PATCH v4 2/5] firmware: arm_scpi: Extend to support sensors Sudeep Holla
[not found] ` <560EB273.7000804-5wv7dgnIgG8@public.gmane.org>
2015-10-05 12:48 ` Punit Agrawal
2015-09-15 16:50 ` [PATCH v4 3/5] hwmon: Support sensors exported via ARM SCP interface Punit Agrawal
2015-09-15 16:51 ` [PATCH v4 4/5] hwmon: Support thermal zones registration for SCP temperature sensors Punit Agrawal
2015-09-15 16:51 ` [PATCH v4 5/5] arm64: dts: Add sensor node to Juno dt Punit Agrawal
[not found] ` <1442335861-7282-6-git-send-email-punit.agrawal-5wv7dgnIgG8@public.gmane.org>
2015-09-24 16:36 ` Liviu Dudau
[not found] ` <20150924163658.GH2368-2JSQmVVBSi7ZROr8t4l/smS4ubULX0JqMm0uRHvK7Nw@public.gmane.org>
2015-09-25 14:37 ` Punit Agrawal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1442335861-7282-3-git-send-email-punit.agrawal@arm.com \
--to=punit.agrawal@arm.com \
--cc=devicetree@vger.kernel.org \
--cc=edubezval@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=liviu.dudau@arm.com \
--cc=mark.rutland@arm.com \
--cc=robh+dt@kernel.org \
--cc=sudeep.holla@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).