From: Neil Armstrong <narmstrong@baylibre.com>
To: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, sudeep.holla@arm.com
Cc: Neil Armstrong <narmstrong@baylibre.com>,
linux-amlogic@lists.infradead.org, khilman@baylibre.com,
heiko@sntech.de, wxt@rock-chips.com, frank.wang@rock-chips.com
Subject: [PATCH 01/13] scpi: Add vendor_send_message to enable access to vendor commands
Date: Thu, 18 Aug 2016 12:10:54 +0200 [thread overview]
Message-ID: <1471515066-3626-2-git-send-email-narmstrong@baylibre.com> (raw)
In-Reply-To: <1471515066-3626-1-git-send-email-narmstrong@baylibre.com>
Adds an optional vendor_send_message to the scpi to enable sending
vendor platform specific commands to the SCP firmware.
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
drivers/firmware/arm_scpi.c | 26 +++++++++++++++++++++++---
include/linux/scpi_protocol.h | 4 ++++
2 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c
index 4388937..403783a 100644
--- a/drivers/firmware/arm_scpi.c
+++ b/drivers/firmware/arm_scpi.c
@@ -46,6 +46,8 @@
#define CMD_ID_SHIFT 0
#define CMD_ID_MASK 0x7f
+#define CMD_SET_SHIFT 7
+#define CMD_SET_MASK 0x1
#define CMD_TOKEN_ID_SHIFT 8
#define CMD_TOKEN_ID_MASK 0xff
#define CMD_DATA_SIZE_SHIFT 16
@@ -53,6 +55,10 @@
#define PACK_SCPI_CMD(cmd_id, tx_sz) \
((((cmd_id) & CMD_ID_MASK) << CMD_ID_SHIFT) | \
(((tx_sz) & CMD_DATA_SIZE_MASK) << CMD_DATA_SIZE_SHIFT))
+#define PACK_EXT_SCPI_CMD(cmd_id, tx_sz) \
+ ((((cmd_id) & CMD_ID_MASK) << CMD_ID_SHIFT) | \
+ (CMD_SET_MASK << CMD_SET_SHIFT) | \
+ (((tx_sz) & CMD_DATA_SIZE_MASK) << CMD_DATA_SIZE_SHIFT))
#define ADD_SCPI_TOKEN(cmd, token) \
((cmd) |= (((token) & CMD_TOKEN_ID_MASK) << CMD_TOKEN_ID_SHIFT))
@@ -344,8 +350,8 @@ static void put_scpi_xfer(struct scpi_xfer *t, struct scpi_chan *ch)
mutex_unlock(&ch->xfers_lock);
}
-static int scpi_send_message(u8 cmd, void *tx_buf, unsigned int tx_len,
- void *rx_buf, unsigned int rx_len)
+static int __scpi_send_message(u8 cmd, void *tx_buf, unsigned int tx_len,
+ void *rx_buf, unsigned int rx_len, bool extn)
{
int ret;
u8 chan;
@@ -360,7 +366,8 @@ static int scpi_send_message(u8 cmd, void *tx_buf, unsigned int tx_len,
return -ENOMEM;
msg->slot = BIT(SCPI_SLOT);
- msg->cmd = PACK_SCPI_CMD(cmd, tx_len);
+ msg->cmd = extn ? PACK_EXT_SCPI_CMD(cmd, tx_len) :
+ PACK_SCPI_CMD(cmd, tx_len);
msg->tx_buf = tx_buf;
msg->tx_len = tx_len;
msg->rx_buf = rx_buf;
@@ -385,6 +392,18 @@ out:
return ret > 0 ? scpi_to_linux_errno(ret) : ret;
}
+static int scpi_send_message(u8 cmd, void *tx_buf, unsigned int tx_len,
+ void *rx_buf, unsigned int rx_len)
+{
+ return __scpi_send_message(cmd, tx_buf, tx_len, rx_buf, rx_len, false);
+}
+
+static int scpi_ext_send_message(u8 cmd, void *tx_buf, unsigned int tx_len,
+ void *rx_buf, unsigned int rx_len)
+{
+ return __scpi_send_message(cmd, tx_buf, tx_len, rx_buf, rx_len, true);
+}
+
static u32 scpi_get_version(void)
{
return scpi_info->protocol_version;
@@ -578,6 +597,7 @@ static struct scpi_ops scpi_ops = {
.sensor_get_value = scpi_sensor_get_value,
.device_get_power_state = scpi_device_get_power_state,
.device_set_power_state = scpi_device_set_power_state,
+ .vendor_send_message = scpi_ext_send_message,
};
struct scpi_ops *get_scpi_ops(void)
diff --git a/include/linux/scpi_protocol.h b/include/linux/scpi_protocol.h
index dc5f989..2b68581 100644
--- a/include/linux/scpi_protocol.h
+++ b/include/linux/scpi_protocol.h
@@ -58,6 +58,8 @@ struct scpi_sensor_info {
* OPP is an index to the list return by @dvfs_get_info
* @dvfs_get_info: returns the DVFS capabilities of the given power
* domain. It includes the OPP list and the latency information
+ * @vendor_send_message: vendor specific message sending, arg can specify
+ * a scpi implementation specific argument
*/
struct scpi_ops {
u32 (*get_version)(void);
@@ -72,6 +74,8 @@ struct scpi_ops {
int (*sensor_get_value)(u16, u64 *);
int (*device_get_power_state)(u16);
int (*device_set_power_state)(u16, u8);
+ int (*vendor_send_message)(u8 cmd, void *tx_buf, unsigned int tx_len,
+ void *rx_buf, unsigned int rx_len);
};
#if IS_REACHABLE(CONFIG_ARM_SCPI_PROTOCOL)
--
1.9.1
next prev parent reply other threads:[~2016-08-18 10:14 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-18 10:10 [PATCH 00/13] scpi: Add support for legacy SCPI protocol Neil Armstrong
2016-08-18 10:10 ` Neil Armstrong [this message]
2016-08-18 15:53 ` [PATCH 01/13] scpi: Add vendor_send_message to enable access to vendor commands Sudeep Holla
2016-08-19 8:00 ` Neil Armstrong
2016-08-19 10:39 ` Sudeep Holla
2016-08-18 10:10 ` [PATCH 02/13] scpi: Add alternative legacy structures and macros Neil Armstrong
2016-08-18 17:16 ` Sudeep Holla
2016-08-23 8:09 ` Neil Armstrong
2016-08-18 10:10 ` [PATCH 03/13] scpi: Add legacy send, prepare and handle remote functions Neil Armstrong
2016-08-19 16:13 ` Sudeep Holla
2016-08-23 8:15 ` Neil Armstrong
2016-08-23 14:42 ` Sudeep Holla
2016-08-18 10:10 ` [PATCH 04/13] scpi: Add legacy SCP functions calling legacy_scpi_send_message Neil Armstrong
2016-08-19 16:22 ` Sudeep Holla
2016-08-23 8:19 ` Neil Armstrong
2016-08-23 14:47 ` Sudeep Holla
2016-08-18 10:10 ` [PATCH 05/13] scpi: move of_match table before probe functions Neil Armstrong
2016-08-19 16:24 ` Sudeep Holla
2016-08-23 8:20 ` Neil Armstrong
2016-08-18 10:10 ` [PATCH 06/13] scpi: add priv_scpi_ops and fill legacy structure Neil Armstrong
2016-08-19 16:39 ` Sudeep Holla
2016-08-23 8:22 ` Neil Armstrong
2016-08-23 14:50 ` Sudeep Holla
2016-08-18 10:11 ` [PATCH 07/13] scpi: ignore init_versions failure if reported not supported Neil Armstrong
2016-08-19 16:46 ` Sudeep Holla
2016-08-23 8:23 ` Neil Armstrong
2016-08-23 14:54 ` Sudeep Holla
2016-08-23 14:55 ` Neil Armstrong
2016-08-23 15:01 ` Sudeep Holla
2016-08-18 10:11 ` [PATCH 08/13] scpi: add a vendor_msg mechanism in case the mailbox message differs Neil Armstrong
2016-08-19 16:47 ` Sudeep Holla
2016-08-18 10:11 ` [PATCH 09/13] scpi: implement rockchip support via the vendor_msg mechanism Neil Armstrong
2016-08-18 10:11 ` [PATCH 10/13] scpi: grow MAX_DVFS_OPPS to 16 entries Neil Armstrong
2016-08-18 10:11 ` [PATCH 11/13] dt-bindings: Add support for Amlogic GXBB SCPI Interface Neil Armstrong
2016-08-19 13:45 ` Rob Herring
2016-08-18 10:11 ` [PATCH 12/13] ARM64: dts: meson-gxbb: Add SRAM node Neil Armstrong
2016-08-18 10:11 ` [PATCH 13/13] ARM64: dts: meson-gxbb: Add SCPI with cpufreq & sensors Nodes Neil Armstrong
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=1471515066-3626-2-git-send-email-narmstrong@baylibre.com \
--to=narmstrong@baylibre.com \
--cc=frank.wang@rock-chips.com \
--cc=heiko@sntech.de \
--cc=khilman@baylibre.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sudeep.holla@arm.com \
--cc=wxt@rock-chips.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).