18c2ecf20Sopenharmony_ciRPMH RSC:
28c2ecf20Sopenharmony_ci------------
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ciResource Power Manager Hardened (RPMH) is the mechanism for communicating with
58c2ecf20Sopenharmony_cithe hardened resource accelerators on Qualcomm SoCs. Requests to the resources
68c2ecf20Sopenharmony_cican be written to the Trigger Command Set (TCS)  registers and using a (addr,
78c2ecf20Sopenharmony_cival) pair and triggered. Messages in the TCS are then sent in sequence over an
88c2ecf20Sopenharmony_ciinternal bus.
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ciThe hardware block (Direct Resource Voter or DRV) is a part of the h/w entity
118c2ecf20Sopenharmony_ci(Resource State Coordinator a.k.a RSC) that can handle multiple sleep and
128c2ecf20Sopenharmony_ciactive/wake resource requests. Multiple such DRVs can exist in a SoC and can
138c2ecf20Sopenharmony_cibe written to from Linux. The structure of each DRV follows the same template
148c2ecf20Sopenharmony_ciwith a few variations that are captured by the properties here.
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ciA TCS may be triggered from Linux or triggered by the F/W after all the CPUs
178c2ecf20Sopenharmony_cihave powered off to facilitate idle power saving. TCS could be classified as -
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci	ACTIVE  /* Triggered by Linux */
208c2ecf20Sopenharmony_ci	SLEEP   /* Triggered by F/W */
218c2ecf20Sopenharmony_ci	WAKE    /* Triggered by F/W */
228c2ecf20Sopenharmony_ci	CONTROL /* Triggered by F/W */
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ciThe order in which they are described in the DT, should match the hardware
258c2ecf20Sopenharmony_ciconfiguration.
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ciRequests can be made for the state of a resource, when the subsystem is active
288c2ecf20Sopenharmony_cior idle. When all subsystems like Modem, GPU, CPU are idle, the resource state
298c2ecf20Sopenharmony_ciwill be an aggregate of the sleep votes from each of those subsystems. Clients
308c2ecf20Sopenharmony_cimay request a sleep value for their shared resources in addition to the active
318c2ecf20Sopenharmony_cimode requests.
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ciProperties:
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci- compatible:
368c2ecf20Sopenharmony_ci	Usage: required
378c2ecf20Sopenharmony_ci	Value type: <string>
388c2ecf20Sopenharmony_ci	Definition: Should be "qcom,rpmh-rsc".
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci- reg:
418c2ecf20Sopenharmony_ci	Usage: required
428c2ecf20Sopenharmony_ci	Value type: <prop-encoded-array>
438c2ecf20Sopenharmony_ci	Definition: The first register specifies the base address of the
448c2ecf20Sopenharmony_ci		    DRV(s). The number of DRVs in the dependent on the RSC.
458c2ecf20Sopenharmony_ci	            The tcs-offset specifies the start address of the
468c2ecf20Sopenharmony_ci	            TCS in the DRVs.
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci- reg-names:
498c2ecf20Sopenharmony_ci	Usage: required
508c2ecf20Sopenharmony_ci	Value type: <string>
518c2ecf20Sopenharmony_ci	Definition: Maps the register specified in the reg property. Must be
528c2ecf20Sopenharmony_ci	            "drv-0", "drv-1", "drv-2" etc and "tcs-offset". The
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci- interrupts:
558c2ecf20Sopenharmony_ci	Usage: required
568c2ecf20Sopenharmony_ci	Value type: <prop-encoded-interrupt>
578c2ecf20Sopenharmony_ci	Definition: The interrupt that trips when a message complete/response
588c2ecf20Sopenharmony_ci	           is received for this DRV from the accelerators.
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci- qcom,drv-id:
618c2ecf20Sopenharmony_ci	Usage: required
628c2ecf20Sopenharmony_ci	Value type: <u32>
638c2ecf20Sopenharmony_ci	Definition: The id of the DRV in the RSC block that will be used by
648c2ecf20Sopenharmony_ci		    this controller.
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci- qcom,tcs-config:
678c2ecf20Sopenharmony_ci	Usage: required
688c2ecf20Sopenharmony_ci	Value type: <prop-encoded-array>
698c2ecf20Sopenharmony_ci	Definition: The tuple defining the configuration of TCS.
708c2ecf20Sopenharmony_ci	            Must have 2 cells which describe each TCS type.
718c2ecf20Sopenharmony_ci	            <type number_of_tcs>.
728c2ecf20Sopenharmony_ci	            The order of the TCS must match the hardware
738c2ecf20Sopenharmony_ci	            configuration.
748c2ecf20Sopenharmony_ci	- Cell #1 (TCS Type): TCS types to be specified -
758c2ecf20Sopenharmony_ci	            ACTIVE_TCS
768c2ecf20Sopenharmony_ci	            SLEEP_TCS
778c2ecf20Sopenharmony_ci	            WAKE_TCS
788c2ecf20Sopenharmony_ci	            CONTROL_TCS
798c2ecf20Sopenharmony_ci	- Cell #2 (Number of TCS): <u32>
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci- label:
828c2ecf20Sopenharmony_ci	Usage: optional
838c2ecf20Sopenharmony_ci	Value type: <string>
848c2ecf20Sopenharmony_ci	Definition: Name for the RSC. The name would be used in trace logs.
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ciDrivers that want to use the RSC to communicate with RPMH must specify their
878c2ecf20Sopenharmony_cibindings as child nodes of the RSC controllers they wish to communicate with.
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ciExample 1:
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ciFor a TCS whose RSC base address is is 0x179C0000 and is at a DRV id of 2, the
928c2ecf20Sopenharmony_ciregister offsets for DRV2 start at 0D00, the register calculations are like
938c2ecf20Sopenharmony_cithis -
948c2ecf20Sopenharmony_ciDRV0: 0x179C0000
958c2ecf20Sopenharmony_ciDRV2: 0x179C0000 + 0x10000 = 0x179D0000
968c2ecf20Sopenharmony_ciDRV2: 0x179C0000 + 0x10000 * 2 = 0x179E0000
978c2ecf20Sopenharmony_ciTCS-OFFSET: 0xD00
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci	apps_rsc: rsc@179c0000 {
1008c2ecf20Sopenharmony_ci		label = "apps_rsc";
1018c2ecf20Sopenharmony_ci		compatible = "qcom,rpmh-rsc";
1028c2ecf20Sopenharmony_ci		reg = <0x179c0000 0x10000>,
1038c2ecf20Sopenharmony_ci		      <0x179d0000 0x10000>,
1048c2ecf20Sopenharmony_ci		      <0x179e0000 0x10000>;
1058c2ecf20Sopenharmony_ci		reg-names = "drv-0", "drv-1", "drv-2";
1068c2ecf20Sopenharmony_ci		interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>,
1078c2ecf20Sopenharmony_ci			     <GIC_SPI 4 IRQ_TYPE_LEVEL_HIGH>,
1088c2ecf20Sopenharmony_ci			     <GIC_SPI 5 IRQ_TYPE_LEVEL_HIGH>;
1098c2ecf20Sopenharmony_ci		qcom,tcs-offset = <0xd00>;
1108c2ecf20Sopenharmony_ci		qcom,drv-id = <2>;
1118c2ecf20Sopenharmony_ci		qcom,tcs-config = <ACTIVE_TCS  2>,
1128c2ecf20Sopenharmony_ci				  <SLEEP_TCS   3>,
1138c2ecf20Sopenharmony_ci				  <WAKE_TCS    3>,
1148c2ecf20Sopenharmony_ci				  <CONTROL_TCS 1>;
1158c2ecf20Sopenharmony_ci	};
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ciExample 2:
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ciFor a TCS whose RSC base address is 0xAF20000 and is at DRV id of 0, the
1208c2ecf20Sopenharmony_ciregister offsets for DRV0 start at 01C00, the register calculations are like
1218c2ecf20Sopenharmony_cithis -
1228c2ecf20Sopenharmony_ciDRV0: 0xAF20000
1238c2ecf20Sopenharmony_ciTCS-OFFSET: 0x1C00
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ci	disp_rsc: rsc@af20000 {
1268c2ecf20Sopenharmony_ci		label = "disp_rsc";
1278c2ecf20Sopenharmony_ci		compatible = "qcom,rpmh-rsc";
1288c2ecf20Sopenharmony_ci		reg = <0xaf20000 0x10000>;
1298c2ecf20Sopenharmony_ci		reg-names = "drv-0";
1308c2ecf20Sopenharmony_ci		interrupts = <GIC_SPI 129 IRQ_TYPE_LEVEL_HIGH>;
1318c2ecf20Sopenharmony_ci		qcom,tcs-offset = <0x1c00>;
1328c2ecf20Sopenharmony_ci		qcom,drv-id = <0>;
1338c2ecf20Sopenharmony_ci		qcom,tcs-config = <ACTIVE_TCS  0>,
1348c2ecf20Sopenharmony_ci				  <SLEEP_TCS   1>,
1358c2ecf20Sopenharmony_ci				  <WAKE_TCS    1>,
1368c2ecf20Sopenharmony_ci				  <CONTROL_TCS 0>;
1378c2ecf20Sopenharmony_ci	};
138