Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aa4f886f authored by Sudeep Holla's avatar Sudeep Holla
Browse files

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: default avatarSudeep Holla <sudeep.holla@arm.com>
parent fe7be8b2
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -13387,7 +13387,8 @@ F: Documentation/devicetree/bindings/arm/arm,sc[mp]i.txt
F:	drivers/clk/clk-scpi.c
F:	drivers/cpufreq/scpi-cpufreq.c
F:	drivers/firmware/arm_scpi.c
F:	include/linux/scpi_protocol.h
F:	drivers/firmware/arm_scmi/
F:	include/linux/sc[mp]i_protocol.h

SYSTEM RESET/SHUTDOWN DRIVERS
M:	Sebastian Reichel <sre@kernel.org>
+21 −0
Original line number Diff line number Diff line
@@ -19,6 +19,27 @@ config ARM_PSCI_CHECKER
	  on and off through hotplug, so for now torture tests and PSCI checker
	  are mutually exclusive.

config ARM_SCMI_PROTOCOL
	bool "ARM System Control and Management Interface (SCMI) Message Protocol"
	depends on ARM || ARM64 || COMPILE_TEST
	depends on MAILBOX
	help
	  ARM System Control and Management Interface (SCMI) protocol is a
	  set of operating system-independent software interfaces that are
	  used in system management. SCMI is extensible and currently provides
	  interfaces for: Discovery and self-description of the interfaces
	  it supports, Power domain management which is the ability to place
	  a given device or domain into the various power-saving states that
	  it supports, Performance management which is the ability to control
	  the performance of a domain that is composed of compute engines
	  such as application processors and other accelerators, Clock
	  management which is the ability to set and inquire rates on platform
	  managed clocks and Sensor management which is the ability to read
	  sensor data, and be notified of sensor value.

	  This protocol library provides interface for all the client drivers
	  making use of the features offered by the SCMI.

config ARM_SCPI_PROTOCOL
	tristate "ARM System Control and Power Interface (SCPI) Message Protocol"
	depends on ARM || ARM64 || COMPILE_TEST
+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ obj-$(CONFIG_QCOM_SCM_32) += qcom_scm-32.o
CFLAGS_qcom_scm-32.o :=$(call as-instr,.arch armv7-a\n.arch_extension sec,-DREQUIRES_SEC=1) -march=armv7-a
obj-$(CONFIG_TI_SCI_PROTOCOL)	+= ti_sci.o

obj-$(CONFIG_ARM_SCMI_PROTOCOL)	+= arm_scmi/
obj-y				+= broadcom/
obj-y				+= meson/
obj-$(CONFIG_GOOGLE_FIRMWARE)	+= google/
+2 −0
Original line number Diff line number Diff line
obj-y	= scmi-driver.o
scmi-driver-y = driver.o
+66 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
/*
 * System Control and Management Interface (SCMI) Message Protocol
 * driver common header file containing some definitions, structures
 * and function prototypes used in all the different SCMI protocols.
 *
 * Copyright (C) 2018 ARM Ltd.
 */

#include <linux/completion.h>
#include <linux/scmi_protocol.h>
#include <linux/types.h>

/**
 * struct scmi_msg_hdr - Message(Tx/Rx) header
 *
 * @id: The identifier of the command being sent
 * @protocol_id: The identifier of the protocol used to send @id command
 * @seq: The token to identify the message. when a message/command returns,
 *       the platform returns the whole message header unmodified including
 *	 the token.
 */
struct scmi_msg_hdr {
	u8 id;
	u8 protocol_id;
	u16 seq;
	u32 status;
	bool poll_completion;
};

/**
 * struct scmi_msg - Message(Tx/Rx) structure
 *
 * @buf: Buffer pointer
 * @len: Length of data in the Buffer
 */
struct scmi_msg {
	void *buf;
	size_t len;
};

/**
 * struct scmi_xfer - Structure representing a message flow
 *
 * @hdr: Transmit message header
 * @tx: Transmit message
 * @rx: Receive message, the buffer should be pre-allocated to store
 *	message. If request-ACK protocol is used, we can reuse the same
 *	buffer for the rx path as we use for the tx path.
 * @done: completion event
 */

struct scmi_xfer {
	void *con_priv;
	struct scmi_msg_hdr hdr;
	struct scmi_msg tx;
	struct scmi_msg rx;
	struct completion done;
};

void scmi_one_xfer_put(const struct scmi_handle *h, struct scmi_xfer *xfer);
int scmi_do_xfer(const struct scmi_handle *h, struct scmi_xfer *xfer);
int scmi_one_xfer_init(const struct scmi_handle *h, u8 msg_id, u8 prot_id,
		       size_t tx_size, size_t rx_size, struct scmi_xfer **p);
int scmi_handle_put(const struct scmi_handle *handle);
struct scmi_handle *scmi_handle_get(struct device *dev);
Loading