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

Commit 49ef9cde authored by Kyle Yan's avatar Kyle Yan Committed by Gerrit - the friendly Code Review server
Browse files

Merge "drivers: mailbox: add TCS Mailbox driver for RPMH communication" into msm-4.8

parents fc14a5b0 88a8fdae
Loading
Loading
Loading
Loading
+160 −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>

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";
		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";
			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
@@ -133,4 +133,12 @@ config BCM_PDC_MBOX
	  Mailbox implementation for the Broadcom PDC ring manager,
	  which provides access to various offload engines on Broadcom
	  SoCs. Say Y here if you want to use the Broadcom PDC.

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
@@ -27,3 +27,5 @@ obj-$(CONFIG_XGENE_SLIMPRO_MBOX) += mailbox-xgene-slimpro.o
obj-$(CONFIG_HI6220_MBOX)	+= hi6220-mailbox.o

obj-$(CONFIG_BCM_PDC_MBOX)	+= bcm-pdc-mailbox.o

obj-$(CONFIG_QTI_RPMH_MBOX)	+= qti-tcs.o
+1049 −0

File added.

Preview size limit exceeded, changes collapsed.

+16 −0
Original line number Diff line number Diff line
/* Copyright (c) 2014-2016, 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