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

Commit 57a76e1e authored by Lina Iyer's avatar Lina Iyer
Browse files

drivers: mailbox: qcom-rpmh: add RPMH mailbox controller for QCOM SoCs



Add RPMH  mailbox controller driver for QCOM SoC's that have hardware
based RPM communication. The hardware IP known as RSC (Resource State
Coordinator) houses a block that is used to send requests to resources
that are shared with one or more processors in the SoC. The Trigger
Control Set (TCS) is a mailbox slot that can house multiple commands and
when triggered will issue these commands to through an internal bus to
the Resource Power Manager Hardened (RPMH) blocks. The resource state
requests are aggregated along with state requests from other processors
in the SoC and the aggregate value is applied on the resource.

Resource requests made while the CPU is running are called Active state
requests and those sent when the CPU is going into low power mode are
called Sleep state requests. Requests sent during the sleep state of the
processor are matched with Wake state request that restore the state of
the resource to previously requested active levels before the processor
can start executing.

Interrupt responses signal the completion of the requests at the RPMH
and the driver notifies the mailbox framework using the tx_done
callbacks.

This is a snapshot as of 'commit b4a69c05b01172 ("drivers: mailbox:
rpmh-mailbox: rename file to match convention")'.

Change-Id: I6354e9a56dcdb61ab189123233ab469e8d345db3
Signed-off-by: default avatarLina Iyer <ilina@codeaurora.org>
parent 8a09f746
Loading
Loading
Loading
Loading
+166 −0
Original line number Diff line number Diff line
TCS Mailbox:
------------

Trigger Command Set (TCS) is the mailbox mechanism for communicating with
the hardened resource accelerators. Requests to the resources can be written
to the mailbox registers and using a (addr, val) pair and triggered. Messages
in the mailbox are then sent in sequence over an internal bus.

The implementation of the TCS mailbox, follows the mailbox controller
architecture [1]. The logical block (DRV) is a part of the h/w entity
(Resource State Coordinator a.k.a RSC) that can handle a multiple sleep and
active/wake resource request related functionality including the mailbox.
Multiple such DRVs can exist in a SoC and can be written to from Linux. The
structure of each DRV follows the same template with a few variations that are
captured by the properties here.

Each DRV could have 'm' TCS instances. Each TCS could have 'n' slots. Each
slot has a header (u32), address (u32), data (u32), status (u32) and a
read-response (u32). A TCS when triggered will send all the enabled commands
of the 'n' commands in that slot in sequence.

A TCS may be triggered from Linux or triggered by the F/W after all the CPUs
have powered off to faciliate idle power saving. TCS could be classified as -

	SLEEP,  /* Triggered by F/W and not by Linux */
	WAKE,   /* Triggered by F/W, may be used by Linux */
	ACTIVE, /* Triggered by Linux */
	CONTROL /* Triggered by F/W */

Requests can be made for the state of a resource, when the subsystem is active
or idle. When all subsystems like Modem, GPU, CPU are idle, the resource state
will be an aggregeate of the sleep votes from each of those subsystem. Drivers
may request a sleep value for their shared resources in addition to the active
mode requests.

Control requests are instance specific requests that may or may not reach an
accelerator. Only one platform device in Linux can request a control channel
on a DRV.

CONTROLLER:
----------

PROPERTIES:

- compatible:
	Usage: required
	Value type: <string>
	Definition: Should be "qcom,tcs-drv".

- reg:
	Usage: required
	Value type: <prop-encoded-array>
	Definition: the first element specifies the base address of the DRV,
	            the second element specifies the size of the region.

- #mbox-cells:
	Usage: required
	Value type: <u32>
	Definition: the number of mail-box cells. Must be 1.

- interrupts:
	Usage: required
	Value type: <prop-encoded-interrupt>
	Definition: the interrupt that trips when a message complete/response
	           is received for this DRV from the accelertors.

- qcom,drv-id:
	Usage: required
	Value type: <u32>
	Definition: the id of the DRV in the RSC block.

- qcom, tcs-config:
	Usage: required
	Value type: <prop-encoded-array>
	Definition: the tuple definining the configuration of TCS.
	            Must have 2 cells which describe each TCS type.
	            <type number_of_tcs>
	- Cell #1 (TCS Type): Only the TCS types can be specified -
		SLEEP_TCS
		WAKE_TCS
		ACTIVE_TCS
		CONTROL_TCS
	- Cell #2 (Number of TCS): <u32>
- label:
	Usage: optional
	Value type: <string>
	Definition: Name for the mailbox. The name would be used in trace logs.

EXAMPLE 1:

For a TCS whose RSC base address is is 0x179C0000 and is at a DRV of 2, the
register offsets for DRV2 start at 0D00, the register calculations are like
this -
First tuple: 0x179C0000 + 0x10000 * 2 = 0x179E0000
Second tuple: 0x179E0000 + 0xD00  = 0x179E0D00

	apps_rsc: mailbox@179e000 {
		compatible = "qcom,tcs_drv";
		label = "apps_rsc";
		reg = <0x179E0000 0x10000>, <0x179E0D00 0x3000>;
		interrupts = <0 5 0>;
		#mbox-cells = <1>;
		qcom,drv-id = <2>;
		qcom,tcs-config = <SLEEP_TCS   3>,
				  <WAKE_TCS    3>,
				  <ACTIVE_TCS  2>,
				  <CONTROL_TCS 1>;
	};

EXAMPLE 2:

For a TCS whose RSC base address is 0xAF20000 and is at DRV of 0, the register
offsets for DRV0 start at 01C00, the register calculations are like this -
First tuple: 0xAF20000
Second tuple: 0xAF20000 + 0x1C00

	disp_rsc: mailbox@af20000 {
		status = "disabled";
		label = "disp_rsc";
		compatible = "qcom,tcs-drv";
		reg = <0xAF20000 0x10000>, <0xAF21C00 0x3000>;
		interrupts = <0 129 0>;
		#mbox-cells = <1>;
		qcom,drv-id = <0>;
		qcom,tcs-config = <SLEEP_TCS 1>,
				<WAKE_TCS    1>,
				<ACTIVE_TCS  0>,
				<CONTROL_TCS 1>;
	};


CLIENT:
-------

A device needing to communicate with the accelerators should specify the
common mailbox client properties described in [1]. mbox-names can be used to
provide a string name optionally for driver to lookup by name.

- mboxes:
	Usage: required, if the device wants to communicate with the mailbox
	Value type: <prop-encoded-array>
	Definition: The tuple has an handle to the mailbox instance the client
	            as the first argument, the second argument must be 0. This
		    is one per MBOX controller addressed.

EXAMPLE:

	leaky_device@0 {
		<...>;
		mbox-names = <"leaky-channel">;
		mboxes = <&tcs_box 0>;
	};

	leaky_device@1 {
		<...>;
		mbox-names = <"apps", "display">;
		mboxes = <&tcs_box 0>, <&dsp_box 0>;
	};

	power_ctrl@0 {
		<...>;
		mbox-names = <"rpmh">;
		mboxes = <&tcs_box 0>;
	};

[1]. Documentation/mailbox.txt
+8 −0
Original line number Diff line number Diff line
@@ -170,4 +170,12 @@ config BCM_FLEXRM_MBOX
	  Mailbox implementation of the Broadcom FlexRM ring manager,
	  which provides access to various offload engines on Broadcom
	  SoCs. Say Y here if you want to use the Broadcom FlexRM.

config QTI_RPMH_MBOX
	bool "TCS Mailbox for QTI RPMH Communication"
	depends on ARCH_QCOM
	help
	  Support for communication with the hardened-RPM blocks in
	  Qualcomm Technologies Inc (QTI) SoCs using TCS hardware mailbox.

endif
+2 −0
Original line number Diff line number Diff line
@@ -35,3 +35,5 @@ obj-$(CONFIG_BCM_FLEXRM_MBOX) += bcm-flexrm-mailbox.o
obj-$(CONFIG_QCOM_APCS_IPC)	+= qcom-apcs-ipc-mailbox.o

obj-$(CONFIG_TEGRA_HSP_MBOX)	+= tegra-hsp.o

obj-$(CONFIG_QTI_RPMH_MBOX)	+= qcom-rpmh-mailbox.o
+1298 −0

File added.

Preview size limit exceeded, changes collapsed.

+16 −0
Original line number Diff line number Diff line
/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#define SLEEP_TCS	0
#define WAKE_TCS	1
#define ACTIVE_TCS	2
#define CONTROL_TCS	3
Loading