Skip to content

Commit aa4f886

Browse files
committed
firmware: arm_scmi: add basic driver infrastructure for SCMI
The SCMI is intended to allow OSPM to manage various functions that are provided by the hardware platform it is running on, including power and performance functions. SCMI provides two levels of abstraction, protocols and transports. Protocols define individual groups of system control and management messages. A protocol specification describes the messages that it supports. Transports describe the method by which protocol messages are communicated between agents and the platform. This patch adds basic infrastructure to manage the message allocation, initialisation, packing/unpacking and shared memory management. Cc: Arnd Bergmann <arnd@arndb.de> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
1 parent fe7be8b commit aa4f886

File tree

7 files changed

+786
-1
lines changed

7 files changed

+786
-1
lines changed

MAINTAINERS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13387,7 +13387,8 @@ F: Documentation/devicetree/bindings/arm/arm,sc[mp]i.txt
1338713387
F: drivers/clk/clk-scpi.c
1338813388
F: drivers/cpufreq/scpi-cpufreq.c
1338913389
F: drivers/firmware/arm_scpi.c
13390-
F: include/linux/scpi_protocol.h
13390+
F: drivers/firmware/arm_scmi/
13391+
F: include/linux/sc[mp]i_protocol.h
1339113392

1339213393
SYSTEM RESET/SHUTDOWN DRIVERS
1339313394
M: Sebastian Reichel <sre@kernel.org>

drivers/firmware/Kconfig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,27 @@ config ARM_PSCI_CHECKER
1919
on and off through hotplug, so for now torture tests and PSCI checker
2020
are mutually exclusive.
2121

22+
config ARM_SCMI_PROTOCOL
23+
bool "ARM System Control and Management Interface (SCMI) Message Protocol"
24+
depends on ARM || ARM64 || COMPILE_TEST
25+
depends on MAILBOX
26+
help
27+
ARM System Control and Management Interface (SCMI) protocol is a
28+
set of operating system-independent software interfaces that are
29+
used in system management. SCMI is extensible and currently provides
30+
interfaces for: Discovery and self-description of the interfaces
31+
it supports, Power domain management which is the ability to place
32+
a given device or domain into the various power-saving states that
33+
it supports, Performance management which is the ability to control
34+
the performance of a domain that is composed of compute engines
35+
such as application processors and other accelerators, Clock
36+
management which is the ability to set and inquire rates on platform
37+
managed clocks and Sensor management which is the ability to read
38+
sensor data, and be notified of sensor value.
39+
40+
This protocol library provides interface for all the client drivers
41+
making use of the features offered by the SCMI.
42+
2243
config ARM_SCPI_PROTOCOL
2344
tristate "ARM System Control and Power Interface (SCPI) Message Protocol"
2445
depends on ARM || ARM64 || COMPILE_TEST

drivers/firmware/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ obj-$(CONFIG_QCOM_SCM_32) += qcom_scm-32.o
2525
CFLAGS_qcom_scm-32.o :=$(call as-instr,.arch armv7-a\n.arch_extension sec,-DREQUIRES_SEC=1) -march=armv7-a
2626
obj-$(CONFIG_TI_SCI_PROTOCOL) += ti_sci.o
2727

28+
obj-$(CONFIG_ARM_SCMI_PROTOCOL) += arm_scmi/
2829
obj-y += broadcom/
2930
obj-y += meson/
3031
obj-$(CONFIG_GOOGLE_FIRMWARE) += google/

drivers/firmware/arm_scmi/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
obj-y = scmi-driver.o
2+
scmi-driver-y = driver.o

drivers/firmware/arm_scmi/common.h

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* System Control and Management Interface (SCMI) Message Protocol
4+
* driver common header file containing some definitions, structures
5+
* and function prototypes used in all the different SCMI protocols.
6+
*
7+
* Copyright (C) 2018 ARM Ltd.
8+
*/
9+
10+
#include <linux/completion.h>
11+
#include <linux/scmi_protocol.h>
12+
#include <linux/types.h>
13+
14+
/**
15+
* struct scmi_msg_hdr - Message(Tx/Rx) header
16+
*
17+
* @id: The identifier of the command being sent
18+
* @protocol_id: The identifier of the protocol used to send @id command
19+
* @seq: The token to identify the message. when a message/command returns,
20+
* the platform returns the whole message header unmodified including
21+
* the token.
22+
*/
23+
struct scmi_msg_hdr {
24+
u8 id;
25+
u8 protocol_id;
26+
u16 seq;
27+
u32 status;
28+
bool poll_completion;
29+
};
30+
31+
/**
32+
* struct scmi_msg - Message(Tx/Rx) structure
33+
*
34+
* @buf: Buffer pointer
35+
* @len: Length of data in the Buffer
36+
*/
37+
struct scmi_msg {
38+
void *buf;
39+
size_t len;
40+
};
41+
42+
/**
43+
* struct scmi_xfer - Structure representing a message flow
44+
*
45+
* @hdr: Transmit message header
46+
* @tx: Transmit message
47+
* @rx: Receive message, the buffer should be pre-allocated to store
48+
* message. If request-ACK protocol is used, we can reuse the same
49+
* buffer for the rx path as we use for the tx path.
50+
* @done: completion event
51+
*/
52+
53+
struct scmi_xfer {
54+
void *con_priv;
55+
struct scmi_msg_hdr hdr;
56+
struct scmi_msg tx;
57+
struct scmi_msg rx;
58+
struct completion done;
59+
};
60+
61+
void scmi_one_xfer_put(const struct scmi_handle *h, struct scmi_xfer *xfer);
62+
int scmi_do_xfer(const struct scmi_handle *h, struct scmi_xfer *xfer);
63+
int scmi_one_xfer_init(const struct scmi_handle *h, u8 msg_id, u8 prot_id,
64+
size_t tx_size, size_t rx_size, struct scmi_xfer **p);
65+
int scmi_handle_put(const struct scmi_handle *handle);
66+
struct scmi_handle *scmi_handle_get(struct device *dev);

0 commit comments

Comments
 (0)