xref: /openbmc/linux/drivers/firmware/ti_sci.h (revision 81f4458c)
11e0a6014SLokesh Vutla // SPDX-License-Identifier: BSD-3-Clause
2aa276781SNishanth Menon /*
3aa276781SNishanth Menon  * Texas Instruments System Control Interface (TISCI) Protocol
4aa276781SNishanth Menon  *
5aa276781SNishanth Menon  * Communication protocol with TI SCI hardware
6aa276781SNishanth Menon  * The system works in a message response protocol
7aa276781SNishanth Menon  * See: http://processors.wiki.ti.com/index.php/TISCI for details
8aa276781SNishanth Menon  *
9aa276781SNishanth Menon  * Copyright (C)  2015-2016 Texas Instruments Incorporated - http://www.ti.com/
10aa276781SNishanth Menon  */
11aa276781SNishanth Menon 
12aa276781SNishanth Menon #ifndef __TI_SCI_H
13aa276781SNishanth Menon #define __TI_SCI_H
14aa276781SNishanth Menon 
15aa276781SNishanth Menon /* Generic Messages */
16aa276781SNishanth Menon #define TI_SCI_MSG_ENABLE_WDT	0x0000
17aa276781SNishanth Menon #define TI_SCI_MSG_WAKE_RESET	0x0001
18aa276781SNishanth Menon #define TI_SCI_MSG_VERSION	0x0002
19aa276781SNishanth Menon #define TI_SCI_MSG_WAKE_REASON	0x0003
20aa276781SNishanth Menon #define TI_SCI_MSG_GOODBYE	0x0004
21912cffb4SNishanth Menon #define TI_SCI_MSG_SYS_RESET	0x0005
22aa276781SNishanth Menon 
239e7d756dSNishanth Menon /* Device requests */
249e7d756dSNishanth Menon #define TI_SCI_MSG_SET_DEVICE_STATE	0x0200
259e7d756dSNishanth Menon #define TI_SCI_MSG_GET_DEVICE_STATE	0x0201
269e7d756dSNishanth Menon #define TI_SCI_MSG_SET_DEVICE_RESETS	0x0202
279e7d756dSNishanth Menon 
289f723220SNishanth Menon /* Clock requests */
299f723220SNishanth Menon #define TI_SCI_MSG_SET_CLOCK_STATE	0x0100
309f723220SNishanth Menon #define TI_SCI_MSG_GET_CLOCK_STATE	0x0101
319f723220SNishanth Menon #define TI_SCI_MSG_SET_CLOCK_PARENT	0x0102
329f723220SNishanth Menon #define TI_SCI_MSG_GET_CLOCK_PARENT	0x0103
339f723220SNishanth Menon #define TI_SCI_MSG_GET_NUM_CLOCK_PARENTS 0x0104
349f723220SNishanth Menon #define TI_SCI_MSG_SET_CLOCK_FREQ	0x010c
359f723220SNishanth Menon #define TI_SCI_MSG_QUERY_CLOCK_FREQ	0x010d
369f723220SNishanth Menon #define TI_SCI_MSG_GET_CLOCK_FREQ	0x010e
379f723220SNishanth Menon 
389c19fb68SLokesh Vutla /* Resource Management Requests */
399c19fb68SLokesh Vutla #define TI_SCI_MSG_GET_RESOURCE_RANGE	0x1500
409c19fb68SLokesh Vutla 
41997b001fSLokesh Vutla /* IRQ requests */
42997b001fSLokesh Vutla #define TI_SCI_MSG_SET_IRQ		0x1000
43997b001fSLokesh Vutla #define TI_SCI_MSG_FREE_IRQ		0x1001
44997b001fSLokesh Vutla 
45aa276781SNishanth Menon /**
46aa276781SNishanth Menon  * struct ti_sci_msg_hdr - Generic Message Header for All messages and responses
47aa276781SNishanth Menon  * @type:	Type of messages: One of TI_SCI_MSG* values
48aa276781SNishanth Menon  * @host:	Host of the message
49aa276781SNishanth Menon  * @seq:	Message identifier indicating a transfer sequence
50aa276781SNishanth Menon  * @flags:	Flag for the message
51aa276781SNishanth Menon  */
52aa276781SNishanth Menon struct ti_sci_msg_hdr {
53aa276781SNishanth Menon 	u16 type;
54aa276781SNishanth Menon 	u8 host;
55aa276781SNishanth Menon 	u8 seq;
56aa276781SNishanth Menon #define TI_SCI_MSG_FLAG(val)			(1 << (val))
57aa276781SNishanth Menon #define TI_SCI_FLAG_REQ_GENERIC_NORESPONSE	0x0
58aa276781SNishanth Menon #define TI_SCI_FLAG_REQ_ACK_ON_RECEIVED		TI_SCI_MSG_FLAG(0)
59aa276781SNishanth Menon #define TI_SCI_FLAG_REQ_ACK_ON_PROCESSED	TI_SCI_MSG_FLAG(1)
60aa276781SNishanth Menon #define TI_SCI_FLAG_RESP_GENERIC_NACK		0x0
61aa276781SNishanth Menon #define TI_SCI_FLAG_RESP_GENERIC_ACK		TI_SCI_MSG_FLAG(1)
62aa276781SNishanth Menon 	/* Additional Flags */
63aa276781SNishanth Menon 	u32 flags;
64aa276781SNishanth Menon } __packed;
65aa276781SNishanth Menon 
66aa276781SNishanth Menon /**
67aa276781SNishanth Menon  * struct ti_sci_msg_resp_version - Response for a message
68aa276781SNishanth Menon  * @hdr:		Generic header
69aa276781SNishanth Menon  * @firmware_description: String describing the firmware
70aa276781SNishanth Menon  * @firmware_revision:	Firmware revision
71aa276781SNishanth Menon  * @abi_major:		Major version of the ABI that firmware supports
72aa276781SNishanth Menon  * @abi_minor:		Minor version of the ABI that firmware supports
73aa276781SNishanth Menon  *
74aa276781SNishanth Menon  * In general, ABI version changes follow the rule that minor version increments
75aa276781SNishanth Menon  * are backward compatible. Major revision changes in ABI may not be
76aa276781SNishanth Menon  * backward compatible.
77aa276781SNishanth Menon  *
78aa276781SNishanth Menon  * Response to a generic message with message type TI_SCI_MSG_VERSION
79aa276781SNishanth Menon  */
80aa276781SNishanth Menon struct ti_sci_msg_resp_version {
81aa276781SNishanth Menon 	struct ti_sci_msg_hdr hdr;
82aa276781SNishanth Menon 	char firmware_description[32];
83aa276781SNishanth Menon 	u16 firmware_revision;
84aa276781SNishanth Menon 	u8 abi_major;
85aa276781SNishanth Menon 	u8 abi_minor;
86aa276781SNishanth Menon } __packed;
87aa276781SNishanth Menon 
889e7d756dSNishanth Menon /**
89912cffb4SNishanth Menon  * struct ti_sci_msg_req_reboot - Reboot the SoC
90912cffb4SNishanth Menon  * @hdr:	Generic Header
91912cffb4SNishanth Menon  *
92912cffb4SNishanth Menon  * Request type is TI_SCI_MSG_SYS_RESET, responded with a generic
93912cffb4SNishanth Menon  * ACK/NACK message.
94912cffb4SNishanth Menon  */
95912cffb4SNishanth Menon struct ti_sci_msg_req_reboot {
96912cffb4SNishanth Menon 	struct ti_sci_msg_hdr hdr;
97912cffb4SNishanth Menon } __packed;
98912cffb4SNishanth Menon 
99912cffb4SNishanth Menon /**
1009e7d756dSNishanth Menon  * struct ti_sci_msg_req_set_device_state - Set the desired state of the device
1019e7d756dSNishanth Menon  * @hdr:		Generic header
1029e7d756dSNishanth Menon  * @id:	Indicates which device to modify
1039e7d756dSNishanth Menon  * @reserved: Reserved space in message, must be 0 for backward compatibility
1049e7d756dSNishanth Menon  * @state: The desired state of the device.
1059e7d756dSNishanth Menon  *
1069e7d756dSNishanth Menon  * Certain flags can also be set to alter the device state:
1079e7d756dSNishanth Menon  * + MSG_FLAG_DEVICE_WAKE_ENABLED - Configure the device to be a wake source.
1089e7d756dSNishanth Menon  * The meaning of this flag will vary slightly from device to device and from
1099e7d756dSNishanth Menon  * SoC to SoC but it generally allows the device to wake the SoC out of deep
1109e7d756dSNishanth Menon  * suspend states.
1119e7d756dSNishanth Menon  * + MSG_FLAG_DEVICE_RESET_ISO - Enable reset isolation for this device.
1129e7d756dSNishanth Menon  * + MSG_FLAG_DEVICE_EXCLUSIVE - Claim this device exclusively. When passed
1139e7d756dSNishanth Menon  * with STATE_RETENTION or STATE_ON, it will claim the device exclusively.
1149e7d756dSNishanth Menon  * If another host already has this device set to STATE_RETENTION or STATE_ON,
1159e7d756dSNishanth Menon  * the message will fail. Once successful, other hosts attempting to set
1169e7d756dSNishanth Menon  * STATE_RETENTION or STATE_ON will fail.
1179e7d756dSNishanth Menon  *
1189e7d756dSNishanth Menon  * Request type is TI_SCI_MSG_SET_DEVICE_STATE, responded with a generic
1199e7d756dSNishanth Menon  * ACK/NACK message.
1209e7d756dSNishanth Menon  */
1219e7d756dSNishanth Menon struct ti_sci_msg_req_set_device_state {
1229e7d756dSNishanth Menon 	/* Additional hdr->flags options */
1239e7d756dSNishanth Menon #define MSG_FLAG_DEVICE_WAKE_ENABLED	TI_SCI_MSG_FLAG(8)
1249e7d756dSNishanth Menon #define MSG_FLAG_DEVICE_RESET_ISO	TI_SCI_MSG_FLAG(9)
1259e7d756dSNishanth Menon #define MSG_FLAG_DEVICE_EXCLUSIVE	TI_SCI_MSG_FLAG(10)
1269e7d756dSNishanth Menon 	struct ti_sci_msg_hdr hdr;
1279e7d756dSNishanth Menon 	u32 id;
1289e7d756dSNishanth Menon 	u32 reserved;
1299e7d756dSNishanth Menon 
1309e7d756dSNishanth Menon #define MSG_DEVICE_SW_STATE_AUTO_OFF	0
1319e7d756dSNishanth Menon #define MSG_DEVICE_SW_STATE_RETENTION	1
1329e7d756dSNishanth Menon #define MSG_DEVICE_SW_STATE_ON		2
1339e7d756dSNishanth Menon 	u8 state;
1349e7d756dSNishanth Menon } __packed;
1359e7d756dSNishanth Menon 
1369e7d756dSNishanth Menon /**
1379e7d756dSNishanth Menon  * struct ti_sci_msg_req_get_device_state - Request to get device.
1389e7d756dSNishanth Menon  * @hdr:		Generic header
1399e7d756dSNishanth Menon  * @id:		Device Identifier
1409e7d756dSNishanth Menon  *
1419e7d756dSNishanth Menon  * Request type is TI_SCI_MSG_GET_DEVICE_STATE, responded device state
1429e7d756dSNishanth Menon  * information
1439e7d756dSNishanth Menon  */
1449e7d756dSNishanth Menon struct ti_sci_msg_req_get_device_state {
1459e7d756dSNishanth Menon 	struct ti_sci_msg_hdr hdr;
1469e7d756dSNishanth Menon 	u32 id;
1479e7d756dSNishanth Menon } __packed;
1489e7d756dSNishanth Menon 
1499e7d756dSNishanth Menon /**
1509e7d756dSNishanth Menon  * struct ti_sci_msg_resp_get_device_state - Response to get device request.
1519e7d756dSNishanth Menon  * @hdr:		Generic header
1529e7d756dSNishanth Menon  * @context_loss_count: Indicates how many times the device has lost context. A
1539e7d756dSNishanth Menon  *	driver can use this monotonic counter to determine if the device has
1549e7d756dSNishanth Menon  *	lost context since the last time this message was exchanged.
1559e7d756dSNishanth Menon  * @resets: Programmed state of the reset lines.
1569e7d756dSNishanth Menon  * @programmed_state:	The state as programmed by set_device.
1579e7d756dSNishanth Menon  *			- Uses the MSG_DEVICE_SW_* macros
1589e7d756dSNishanth Menon  * @current_state:	The actual state of the hardware.
1599e7d756dSNishanth Menon  *
1609e7d756dSNishanth Menon  * Response to request TI_SCI_MSG_GET_DEVICE_STATE.
1619e7d756dSNishanth Menon  */
1629e7d756dSNishanth Menon struct ti_sci_msg_resp_get_device_state {
1639e7d756dSNishanth Menon 	struct ti_sci_msg_hdr hdr;
1649e7d756dSNishanth Menon 	u32 context_loss_count;
1659e7d756dSNishanth Menon 	u32 resets;
1669e7d756dSNishanth Menon 	u8 programmed_state;
1679e7d756dSNishanth Menon #define MSG_DEVICE_HW_STATE_OFF		0
1689e7d756dSNishanth Menon #define MSG_DEVICE_HW_STATE_ON		1
1699e7d756dSNishanth Menon #define MSG_DEVICE_HW_STATE_TRANS	2
1709e7d756dSNishanth Menon 	u8 current_state;
1719e7d756dSNishanth Menon } __packed;
1729e7d756dSNishanth Menon 
1739e7d756dSNishanth Menon /**
1749e7d756dSNishanth Menon  * struct ti_sci_msg_req_set_device_resets - Set the desired resets
1759e7d756dSNishanth Menon  *				configuration of the device
1769e7d756dSNishanth Menon  * @hdr:		Generic header
1779e7d756dSNishanth Menon  * @id:	Indicates which device to modify
1789e7d756dSNishanth Menon  * @resets: A bit field of resets for the device. The meaning, behavior,
1799e7d756dSNishanth Menon  *	and usage of the reset flags are device specific. 0 for a bit
1809e7d756dSNishanth Menon  *	indicates releasing the reset represented by that bit while 1
1819e7d756dSNishanth Menon  *	indicates keeping it held.
1829e7d756dSNishanth Menon  *
1839e7d756dSNishanth Menon  * Request type is TI_SCI_MSG_SET_DEVICE_RESETS, responded with a generic
1849e7d756dSNishanth Menon  * ACK/NACK message.
1859e7d756dSNishanth Menon  */
1869e7d756dSNishanth Menon struct ti_sci_msg_req_set_device_resets {
1879e7d756dSNishanth Menon 	struct ti_sci_msg_hdr hdr;
1889e7d756dSNishanth Menon 	u32 id;
1899e7d756dSNishanth Menon 	u32 resets;
1909e7d756dSNishanth Menon } __packed;
1919e7d756dSNishanth Menon 
1929f723220SNishanth Menon /**
1939f723220SNishanth Menon  * struct ti_sci_msg_req_set_clock_state - Request to setup a Clock state
1949f723220SNishanth Menon  * @hdr:	Generic Header, Certain flags can be set specific to the clocks:
1959f723220SNishanth Menon  *		MSG_FLAG_CLOCK_ALLOW_SSC: Allow this clock to be modified
1969f723220SNishanth Menon  *		via spread spectrum clocking.
1979f723220SNishanth Menon  *		MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE: Allow this clock's
1989f723220SNishanth Menon  *		frequency to be changed while it is running so long as it
1999f723220SNishanth Menon  *		is within the min/max limits.
2009f723220SNishanth Menon  *		MSG_FLAG_CLOCK_INPUT_TERM: Enable input termination, this
2019f723220SNishanth Menon  *		is only applicable to clock inputs on the SoC pseudo-device.
2029f723220SNishanth Menon  * @dev_id:	Device identifier this request is for
2039f723220SNishanth Menon  * @clk_id:	Clock identifier for the device for this request.
2049f723220SNishanth Menon  *		Each device has it's own set of clock inputs. This indexes
20581f4458cSTero Kristo  *		which clock input to modify. Set to 255 if clock ID is
20681f4458cSTero Kristo  *		greater than or equal to 255.
2079f723220SNishanth Menon  * @request_state: Request the state for the clock to be set to.
2089f723220SNishanth Menon  *		MSG_CLOCK_SW_STATE_UNREQ: The IP does not require this clock,
2099f723220SNishanth Menon  *		it can be disabled, regardless of the state of the device
2109f723220SNishanth Menon  *		MSG_CLOCK_SW_STATE_AUTO: Allow the System Controller to
2119f723220SNishanth Menon  *		automatically manage the state of this clock. If the device
2129f723220SNishanth Menon  *		is enabled, then the clock is enabled. If the device is set
2139f723220SNishanth Menon  *		to off or retention, then the clock is internally set as not
2149f723220SNishanth Menon  *		being required by the device.(default)
2159f723220SNishanth Menon  *		MSG_CLOCK_SW_STATE_REQ:  Configure the clock to be enabled,
2169f723220SNishanth Menon  *		regardless of the state of the device.
21781f4458cSTero Kristo  * @clk_id_32:	Clock identifier for the device for this request.
21881f4458cSTero Kristo  *		Only to be used if the clock ID is greater than or equal to
21981f4458cSTero Kristo  *		255.
2209f723220SNishanth Menon  *
2219f723220SNishanth Menon  * Normally, all required clocks are managed by TISCI entity, this is used
2229f723220SNishanth Menon  * only for specific control *IF* required. Auto managed state is
2239f723220SNishanth Menon  * MSG_CLOCK_SW_STATE_AUTO, in other states, TISCI entity assume remote
2249f723220SNishanth Menon  * will explicitly control.
2259f723220SNishanth Menon  *
2269f723220SNishanth Menon  * Request type is TI_SCI_MSG_SET_CLOCK_STATE, response is a generic
2279f723220SNishanth Menon  * ACK or NACK message.
2289f723220SNishanth Menon  */
2299f723220SNishanth Menon struct ti_sci_msg_req_set_clock_state {
2309f723220SNishanth Menon 	/* Additional hdr->flags options */
2319f723220SNishanth Menon #define MSG_FLAG_CLOCK_ALLOW_SSC		TI_SCI_MSG_FLAG(8)
2329f723220SNishanth Menon #define MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE	TI_SCI_MSG_FLAG(9)
2339f723220SNishanth Menon #define MSG_FLAG_CLOCK_INPUT_TERM		TI_SCI_MSG_FLAG(10)
2349f723220SNishanth Menon 	struct ti_sci_msg_hdr hdr;
2359f723220SNishanth Menon 	u32 dev_id;
2369f723220SNishanth Menon 	u8 clk_id;
2379f723220SNishanth Menon #define MSG_CLOCK_SW_STATE_UNREQ	0
2389f723220SNishanth Menon #define MSG_CLOCK_SW_STATE_AUTO		1
2399f723220SNishanth Menon #define MSG_CLOCK_SW_STATE_REQ		2
2409f723220SNishanth Menon 	u8 request_state;
24181f4458cSTero Kristo 	u32 clk_id_32;
2429f723220SNishanth Menon } __packed;
2439f723220SNishanth Menon 
2449f723220SNishanth Menon /**
2459f723220SNishanth Menon  * struct ti_sci_msg_req_get_clock_state - Request for clock state
2469f723220SNishanth Menon  * @hdr:	Generic Header
2479f723220SNishanth Menon  * @dev_id:	Device identifier this request is for
2489f723220SNishanth Menon  * @clk_id:	Clock identifier for the device for this request.
2499f723220SNishanth Menon  *		Each device has it's own set of clock inputs. This indexes
25081f4458cSTero Kristo  *		which clock input to get state of. Set to 255 if the clock
25181f4458cSTero Kristo  *		ID is greater than or equal to 255.
25281f4458cSTero Kristo  * @clk_id_32:	Clock identifier for the device for the request.
25381f4458cSTero Kristo  *		Only to be used if the clock ID is greater than or equal to
25481f4458cSTero Kristo  *		255.
2559f723220SNishanth Menon  *
2569f723220SNishanth Menon  * Request type is TI_SCI_MSG_GET_CLOCK_STATE, response is state
2579f723220SNishanth Menon  * of the clock
2589f723220SNishanth Menon  */
2599f723220SNishanth Menon struct ti_sci_msg_req_get_clock_state {
2609f723220SNishanth Menon 	struct ti_sci_msg_hdr hdr;
2619f723220SNishanth Menon 	u32 dev_id;
2629f723220SNishanth Menon 	u8 clk_id;
26381f4458cSTero Kristo 	u32 clk_id_32;
2649f723220SNishanth Menon } __packed;
2659f723220SNishanth Menon 
2669f723220SNishanth Menon /**
2679f723220SNishanth Menon  * struct ti_sci_msg_resp_get_clock_state - Response to get clock state
2689f723220SNishanth Menon  * @hdr:	Generic Header
2699f723220SNishanth Menon  * @programmed_state: Any programmed state of the clock. This is one of
2709f723220SNishanth Menon  *		MSG_CLOCK_SW_STATE* values.
2719f723220SNishanth Menon  * @current_state: Current state of the clock. This is one of:
2729f723220SNishanth Menon  *		MSG_CLOCK_HW_STATE_NOT_READY: Clock is not ready
2739f723220SNishanth Menon  *		MSG_CLOCK_HW_STATE_READY: Clock is ready
2749f723220SNishanth Menon  *
2759f723220SNishanth Menon  * Response to TI_SCI_MSG_GET_CLOCK_STATE.
2769f723220SNishanth Menon  */
2779f723220SNishanth Menon struct ti_sci_msg_resp_get_clock_state {
2789f723220SNishanth Menon 	struct ti_sci_msg_hdr hdr;
2799f723220SNishanth Menon 	u8 programmed_state;
2809f723220SNishanth Menon #define MSG_CLOCK_HW_STATE_NOT_READY	0
2819f723220SNishanth Menon #define MSG_CLOCK_HW_STATE_READY	1
2829f723220SNishanth Menon 	u8 current_state;
2839f723220SNishanth Menon } __packed;
2849f723220SNishanth Menon 
2859f723220SNishanth Menon /**
2869f723220SNishanth Menon  * struct ti_sci_msg_req_set_clock_parent - Set the clock parent
2879f723220SNishanth Menon  * @hdr:	Generic Header
2889f723220SNishanth Menon  * @dev_id:	Device identifier this request is for
2899f723220SNishanth Menon  * @clk_id:	Clock identifier for the device for this request.
2909f723220SNishanth Menon  *		Each device has it's own set of clock inputs. This indexes
29181f4458cSTero Kristo  *		which clock input to modify. Set to 255 if clock ID is
29281f4458cSTero Kristo  *		greater than or equal to 255.
2939f723220SNishanth Menon  * @parent_id:	The new clock parent is selectable by an index via this
29481f4458cSTero Kristo  *		parameter. Set to 255 if clock ID is greater than or
29581f4458cSTero Kristo  *		equal to 255.
29681f4458cSTero Kristo  * @clk_id_32:	Clock identifier if @clk_id field is 255.
29781f4458cSTero Kristo  * @parent_id_32:	Parent identifier if @parent_id is 255.
2989f723220SNishanth Menon  *
2999f723220SNishanth Menon  * Request type is TI_SCI_MSG_SET_CLOCK_PARENT, response is generic
3009f723220SNishanth Menon  * ACK / NACK message.
3019f723220SNishanth Menon  */
3029f723220SNishanth Menon struct ti_sci_msg_req_set_clock_parent {
3039f723220SNishanth Menon 	struct ti_sci_msg_hdr hdr;
3049f723220SNishanth Menon 	u32 dev_id;
3059f723220SNishanth Menon 	u8 clk_id;
3069f723220SNishanth Menon 	u8 parent_id;
30781f4458cSTero Kristo 	u32 clk_id_32;
30881f4458cSTero Kristo 	u32 parent_id_32;
3099f723220SNishanth Menon } __packed;
3109f723220SNishanth Menon 
3119f723220SNishanth Menon /**
3129f723220SNishanth Menon  * struct ti_sci_msg_req_get_clock_parent - Get the clock parent
3139f723220SNishanth Menon  * @hdr:	Generic Header
3149f723220SNishanth Menon  * @dev_id:	Device identifier this request is for
3159f723220SNishanth Menon  * @clk_id:	Clock identifier for the device for this request.
3169f723220SNishanth Menon  *		Each device has it's own set of clock inputs. This indexes
31781f4458cSTero Kristo  *		which clock input to get the parent for. If this field
31881f4458cSTero Kristo  *		contains 255, the actual clock identifier is stored in
31981f4458cSTero Kristo  *		@clk_id_32.
32081f4458cSTero Kristo  * @clk_id_32:	Clock identifier if the @clk_id field contains 255.
3219f723220SNishanth Menon  *
3229f723220SNishanth Menon  * Request type is TI_SCI_MSG_GET_CLOCK_PARENT, response is parent information
3239f723220SNishanth Menon  */
3249f723220SNishanth Menon struct ti_sci_msg_req_get_clock_parent {
3259f723220SNishanth Menon 	struct ti_sci_msg_hdr hdr;
3269f723220SNishanth Menon 	u32 dev_id;
3279f723220SNishanth Menon 	u8 clk_id;
32881f4458cSTero Kristo 	u32 clk_id_32;
3299f723220SNishanth Menon } __packed;
3309f723220SNishanth Menon 
3319f723220SNishanth Menon /**
3329f723220SNishanth Menon  * struct ti_sci_msg_resp_get_clock_parent - Response with clock parent
3339f723220SNishanth Menon  * @hdr:	Generic Header
33481f4458cSTero Kristo  * @parent_id:	The current clock parent. If set to 255, the current parent
33581f4458cSTero Kristo  *		ID can be found from the @parent_id_32 field.
33681f4458cSTero Kristo  * @parent_id_32:	Current clock parent if @parent_id field is set to
33781f4458cSTero Kristo  *			255.
3389f723220SNishanth Menon  *
3399f723220SNishanth Menon  * Response to TI_SCI_MSG_GET_CLOCK_PARENT.
3409f723220SNishanth Menon  */
3419f723220SNishanth Menon struct ti_sci_msg_resp_get_clock_parent {
3429f723220SNishanth Menon 	struct ti_sci_msg_hdr hdr;
3439f723220SNishanth Menon 	u8 parent_id;
34481f4458cSTero Kristo 	u32 parent_id_32;
3459f723220SNishanth Menon } __packed;
3469f723220SNishanth Menon 
3479f723220SNishanth Menon /**
3489f723220SNishanth Menon  * struct ti_sci_msg_req_get_clock_num_parents - Request to get clock parents
3499f723220SNishanth Menon  * @hdr:	Generic header
3509f723220SNishanth Menon  * @dev_id:	Device identifier this request is for
35181f4458cSTero Kristo  * @clk_id:	Clock identifier for the device for this request. Set to
35281f4458cSTero Kristo  *		255 if clock ID is greater than or equal to 255.
35381f4458cSTero Kristo  * @clk_id_32:	Clock identifier if the @clk_id field contains 255.
3549f723220SNishanth Menon  *
3559f723220SNishanth Menon  * This request provides information about how many clock parent options
3569f723220SNishanth Menon  * are available for a given clock to a device. This is typically used
3579f723220SNishanth Menon  * for input clocks.
3589f723220SNishanth Menon  *
3599f723220SNishanth Menon  * Request type is TI_SCI_MSG_GET_NUM_CLOCK_PARENTS, response is appropriate
3609f723220SNishanth Menon  * message, or NACK in case of inability to satisfy request.
3619f723220SNishanth Menon  */
3629f723220SNishanth Menon struct ti_sci_msg_req_get_clock_num_parents {
3639f723220SNishanth Menon 	struct ti_sci_msg_hdr hdr;
3649f723220SNishanth Menon 	u32 dev_id;
3659f723220SNishanth Menon 	u8 clk_id;
36681f4458cSTero Kristo 	u32 clk_id_32;
3679f723220SNishanth Menon } __packed;
3689f723220SNishanth Menon 
3699f723220SNishanth Menon /**
3709f723220SNishanth Menon  * struct ti_sci_msg_resp_get_clock_num_parents - Response for get clk parents
3719f723220SNishanth Menon  * @hdr:		Generic header
37281f4458cSTero Kristo  * @num_parents:	Number of clock parents. If set to 255, the actual
37381f4458cSTero Kristo  *			number of parents is stored into @num_parents_32
37481f4458cSTero Kristo  *			field instead.
37581f4458cSTero Kristo  * @num_parents_32:	Number of clock parents if @num_parents field is
37681f4458cSTero Kristo  *			set to 255.
3779f723220SNishanth Menon  *
3789f723220SNishanth Menon  * Response to TI_SCI_MSG_GET_NUM_CLOCK_PARENTS
3799f723220SNishanth Menon  */
3809f723220SNishanth Menon struct ti_sci_msg_resp_get_clock_num_parents {
3819f723220SNishanth Menon 	struct ti_sci_msg_hdr hdr;
3829f723220SNishanth Menon 	u8 num_parents;
38381f4458cSTero Kristo 	u32 num_parents_32;
3849f723220SNishanth Menon } __packed;
3859f723220SNishanth Menon 
3869f723220SNishanth Menon /**
3879f723220SNishanth Menon  * struct ti_sci_msg_req_query_clock_freq - Request to query a frequency
3889f723220SNishanth Menon  * @hdr:	Generic Header
3899f723220SNishanth Menon  * @dev_id:	Device identifier this request is for
3909f723220SNishanth Menon  * @min_freq_hz: The minimum allowable frequency in Hz. This is the minimum
3919f723220SNishanth Menon  *		allowable programmed frequency and does not account for clock
3929f723220SNishanth Menon  *		tolerances and jitter.
3939f723220SNishanth Menon  * @target_freq_hz: The target clock frequency. A frequency will be found
3949f723220SNishanth Menon  *		as close to this target frequency as possible.
3959f723220SNishanth Menon  * @max_freq_hz: The maximum allowable frequency in Hz. This is the maximum
3969f723220SNishanth Menon  *		allowable programmed frequency and does not account for clock
3979f723220SNishanth Menon  *		tolerances and jitter.
39881f4458cSTero Kristo  * @clk_id:	Clock identifier for the device for this request. Set to
39981f4458cSTero Kristo  *		255 if clock identifier is greater than or equal to 255.
40081f4458cSTero Kristo  * @clk_id_32:	Clock identifier if @clk_id is set to 255.
4019f723220SNishanth Menon  *
4029f723220SNishanth Menon  * NOTE: Normally clock frequency management is automatically done by TISCI
4039f723220SNishanth Menon  * entity. In case of specific requests, TISCI evaluates capability to achieve
4049f723220SNishanth Menon  * requested frequency within provided range and responds with
4059f723220SNishanth Menon  * result message.
4069f723220SNishanth Menon  *
4079f723220SNishanth Menon  * Request type is TI_SCI_MSG_QUERY_CLOCK_FREQ, response is appropriate message,
4089f723220SNishanth Menon  * or NACK in case of inability to satisfy request.
4099f723220SNishanth Menon  */
4109f723220SNishanth Menon struct ti_sci_msg_req_query_clock_freq {
4119f723220SNishanth Menon 	struct ti_sci_msg_hdr hdr;
4129f723220SNishanth Menon 	u32 dev_id;
4139f723220SNishanth Menon 	u64 min_freq_hz;
4149f723220SNishanth Menon 	u64 target_freq_hz;
4159f723220SNishanth Menon 	u64 max_freq_hz;
4169f723220SNishanth Menon 	u8 clk_id;
41781f4458cSTero Kristo 	u32 clk_id_32;
4189f723220SNishanth Menon } __packed;
4199f723220SNishanth Menon 
4209f723220SNishanth Menon /**
4219f723220SNishanth Menon  * struct ti_sci_msg_resp_query_clock_freq - Response to a clock frequency query
4229f723220SNishanth Menon  * @hdr:	Generic Header
4239f723220SNishanth Menon  * @freq_hz:	Frequency that is the best match in Hz.
4249f723220SNishanth Menon  *
4259f723220SNishanth Menon  * Response to request type TI_SCI_MSG_QUERY_CLOCK_FREQ. NOTE: if the request
4269f723220SNishanth Menon  * cannot be satisfied, the message will be of type NACK.
4279f723220SNishanth Menon  */
4289f723220SNishanth Menon struct ti_sci_msg_resp_query_clock_freq {
4299f723220SNishanth Menon 	struct ti_sci_msg_hdr hdr;
4309f723220SNishanth Menon 	u64 freq_hz;
4319f723220SNishanth Menon } __packed;
4329f723220SNishanth Menon 
4339f723220SNishanth Menon /**
4349f723220SNishanth Menon  * struct ti_sci_msg_req_set_clock_freq - Request to setup a clock frequency
4359f723220SNishanth Menon  * @hdr:	Generic Header
4369f723220SNishanth Menon  * @dev_id:	Device identifier this request is for
4379f723220SNishanth Menon  * @min_freq_hz: The minimum allowable frequency in Hz. This is the minimum
4389f723220SNishanth Menon  *		allowable programmed frequency and does not account for clock
4399f723220SNishanth Menon  *		tolerances and jitter.
4409f723220SNishanth Menon  * @target_freq_hz: The target clock frequency. The clock will be programmed
4419f723220SNishanth Menon  *		at a rate as close to this target frequency as possible.
4429f723220SNishanth Menon  * @max_freq_hz: The maximum allowable frequency in Hz. This is the maximum
4439f723220SNishanth Menon  *		allowable programmed frequency and does not account for clock
4449f723220SNishanth Menon  *		tolerances and jitter.
44581f4458cSTero Kristo  * @clk_id:	Clock identifier for the device for this request. Set to
44681f4458cSTero Kristo  *		255 if clock ID is greater than or equal to 255.
44781f4458cSTero Kristo  * @clk_id_32:	Clock identifier if @clk_id field is set to 255.
4489f723220SNishanth Menon  *
4499f723220SNishanth Menon  * NOTE: Normally clock frequency management is automatically done by TISCI
4509f723220SNishanth Menon  * entity. In case of specific requests, TISCI evaluates capability to achieve
4519f723220SNishanth Menon  * requested range and responds with success/failure message.
4529f723220SNishanth Menon  *
4539f723220SNishanth Menon  * This sets the desired frequency for a clock within an allowable
4549f723220SNishanth Menon  * range. This message will fail on an enabled clock unless
4559f723220SNishanth Menon  * MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE is set for the clock. Additionally,
4569f723220SNishanth Menon  * if other clocks have their frequency modified due to this message,
4579f723220SNishanth Menon  * they also must have the MSG_FLAG_CLOCK_ALLOW_FREQ_CHANGE or be disabled.
4589f723220SNishanth Menon  *
4599f723220SNishanth Menon  * Calling set frequency on a clock input to the SoC pseudo-device will
4609f723220SNishanth Menon  * inform the PMMC of that clock's frequency. Setting a frequency of
4619f723220SNishanth Menon  * zero will indicate the clock is disabled.
4629f723220SNishanth Menon  *
4639f723220SNishanth Menon  * Calling set frequency on clock outputs from the SoC pseudo-device will
4649f723220SNishanth Menon  * function similarly to setting the clock frequency on a device.
4659f723220SNishanth Menon  *
4669f723220SNishanth Menon  * Request type is TI_SCI_MSG_SET_CLOCK_FREQ, response is a generic ACK/NACK
4679f723220SNishanth Menon  * message.
4689f723220SNishanth Menon  */
4699f723220SNishanth Menon struct ti_sci_msg_req_set_clock_freq {
4709f723220SNishanth Menon 	struct ti_sci_msg_hdr hdr;
4719f723220SNishanth Menon 	u32 dev_id;
4729f723220SNishanth Menon 	u64 min_freq_hz;
4739f723220SNishanth Menon 	u64 target_freq_hz;
4749f723220SNishanth Menon 	u64 max_freq_hz;
4759f723220SNishanth Menon 	u8 clk_id;
47681f4458cSTero Kristo 	u32 clk_id_32;
4779f723220SNishanth Menon } __packed;
4789f723220SNishanth Menon 
4799f723220SNishanth Menon /**
4809f723220SNishanth Menon  * struct ti_sci_msg_req_get_clock_freq - Request to get the clock frequency
4819f723220SNishanth Menon  * @hdr:	Generic Header
4829f723220SNishanth Menon  * @dev_id:	Device identifier this request is for
48381f4458cSTero Kristo  * @clk_id:	Clock identifier for the device for this request. Set to
48481f4458cSTero Kristo  *		255 if clock ID is greater than or equal to 255.
48581f4458cSTero Kristo  * @clk_id_32:	Clock identifier if @clk_id field is set to 255.
4869f723220SNishanth Menon  *
4879f723220SNishanth Menon  * NOTE: Normally clock frequency management is automatically done by TISCI
4889f723220SNishanth Menon  * entity. In some cases, clock frequencies are configured by host.
4899f723220SNishanth Menon  *
4909f723220SNishanth Menon  * Request type is TI_SCI_MSG_GET_CLOCK_FREQ, responded with clock frequency
4919f723220SNishanth Menon  * that the clock is currently at.
4929f723220SNishanth Menon  */
4939f723220SNishanth Menon struct ti_sci_msg_req_get_clock_freq {
4949f723220SNishanth Menon 	struct ti_sci_msg_hdr hdr;
4959f723220SNishanth Menon 	u32 dev_id;
4969f723220SNishanth Menon 	u8 clk_id;
49781f4458cSTero Kristo 	u32 clk_id_32;
4989f723220SNishanth Menon } __packed;
4999f723220SNishanth Menon 
5009f723220SNishanth Menon /**
5019f723220SNishanth Menon  * struct ti_sci_msg_resp_get_clock_freq - Response of clock frequency request
5029f723220SNishanth Menon  * @hdr:	Generic Header
5039f723220SNishanth Menon  * @freq_hz:	Frequency that the clock is currently on, in Hz.
5049f723220SNishanth Menon  *
5059f723220SNishanth Menon  * Response to request type TI_SCI_MSG_GET_CLOCK_FREQ.
5069f723220SNishanth Menon  */
5079f723220SNishanth Menon struct ti_sci_msg_resp_get_clock_freq {
5089f723220SNishanth Menon 	struct ti_sci_msg_hdr hdr;
5099f723220SNishanth Menon 	u64 freq_hz;
5109f723220SNishanth Menon } __packed;
5119f723220SNishanth Menon 
5129c19fb68SLokesh Vutla #define TI_SCI_IRQ_SECONDARY_HOST_INVALID	0xff
5139c19fb68SLokesh Vutla 
5149c19fb68SLokesh Vutla /**
5159c19fb68SLokesh Vutla  * struct ti_sci_msg_req_get_resource_range - Request to get a host's assigned
5169c19fb68SLokesh Vutla  *					      range of resources.
5179c19fb68SLokesh Vutla  * @hdr:		Generic Header
5189c19fb68SLokesh Vutla  * @type:		Unique resource assignment type
5199c19fb68SLokesh Vutla  * @subtype:		Resource assignment subtype within the resource type.
5209c19fb68SLokesh Vutla  * @secondary_host:	Host processing entity to which the resources are
5219c19fb68SLokesh Vutla  *			allocated. This is required only when the destination
5229c19fb68SLokesh Vutla  *			host id id different from ti sci interface host id,
5239c19fb68SLokesh Vutla  *			else TI_SCI_IRQ_SECONDARY_HOST_INVALID can be passed.
5249c19fb68SLokesh Vutla  *
5259c19fb68SLokesh Vutla  * Request type is TI_SCI_MSG_GET_RESOURCE_RANGE. Responded with requested
5269c19fb68SLokesh Vutla  * resource range which is of type TI_SCI_MSG_GET_RESOURCE_RANGE.
5279c19fb68SLokesh Vutla  */
5289c19fb68SLokesh Vutla struct ti_sci_msg_req_get_resource_range {
5299c19fb68SLokesh Vutla 	struct ti_sci_msg_hdr hdr;
5309c19fb68SLokesh Vutla #define MSG_RM_RESOURCE_TYPE_MASK	GENMASK(9, 0)
5319c19fb68SLokesh Vutla #define MSG_RM_RESOURCE_SUBTYPE_MASK	GENMASK(5, 0)
5329c19fb68SLokesh Vutla 	u16 type;
5339c19fb68SLokesh Vutla 	u8 subtype;
5349c19fb68SLokesh Vutla 	u8 secondary_host;
5359c19fb68SLokesh Vutla } __packed;
5369c19fb68SLokesh Vutla 
5379c19fb68SLokesh Vutla /**
5389c19fb68SLokesh Vutla  * struct ti_sci_msg_resp_get_resource_range - Response to resource get range.
5399c19fb68SLokesh Vutla  * @hdr:		Generic Header
5409c19fb68SLokesh Vutla  * @range_start:	Start index of the resource range.
5419c19fb68SLokesh Vutla  * @range_num:		Number of resources in the range.
5429c19fb68SLokesh Vutla  *
5439c19fb68SLokesh Vutla  * Response to request TI_SCI_MSG_GET_RESOURCE_RANGE.
5449c19fb68SLokesh Vutla  */
5459c19fb68SLokesh Vutla struct ti_sci_msg_resp_get_resource_range {
5469c19fb68SLokesh Vutla 	struct ti_sci_msg_hdr hdr;
5479c19fb68SLokesh Vutla 	u16 range_start;
5489c19fb68SLokesh Vutla 	u16 range_num;
5499c19fb68SLokesh Vutla } __packed;
5509c19fb68SLokesh Vutla 
551997b001fSLokesh Vutla /**
552997b001fSLokesh Vutla  * struct ti_sci_msg_req_manage_irq - Request to configure/release the route
553997b001fSLokesh Vutla  *					between the dev and the host.
554997b001fSLokesh Vutla  * @hdr:		Generic Header
555997b001fSLokesh Vutla  * @valid_params:	Bit fields defining the validity of interrupt source
556997b001fSLokesh Vutla  *			parameters. If a bit is not set, then corresponding
557997b001fSLokesh Vutla  *			field is not valid and will not be used for route set.
558997b001fSLokesh Vutla  *			Bit field definitions:
559997b001fSLokesh Vutla  *			0 - Valid bit for @dst_id
560997b001fSLokesh Vutla  *			1 - Valid bit for @dst_host_irq
561997b001fSLokesh Vutla  *			2 - Valid bit for @ia_id
562997b001fSLokesh Vutla  *			3 - Valid bit for @vint
563997b001fSLokesh Vutla  *			4 - Valid bit for @global_event
564997b001fSLokesh Vutla  *			5 - Valid bit for @vint_status_bit_index
565997b001fSLokesh Vutla  *			31 - Valid bit for @secondary_host
566997b001fSLokesh Vutla  * @src_id:		IRQ source peripheral ID.
567997b001fSLokesh Vutla  * @src_index:		IRQ source index within the peripheral
568997b001fSLokesh Vutla  * @dst_id:		IRQ Destination ID. Based on the architecture it can be
569997b001fSLokesh Vutla  *			IRQ controller or host processor ID.
570997b001fSLokesh Vutla  * @dst_host_irq:	IRQ number of the destination host IRQ controller
571997b001fSLokesh Vutla  * @ia_id:		Device ID of the interrupt aggregator in which the
572997b001fSLokesh Vutla  *			vint resides.
573997b001fSLokesh Vutla  * @vint:		Virtual interrupt number if the interrupt route
574997b001fSLokesh Vutla  *			is through an interrupt aggregator.
575997b001fSLokesh Vutla  * @global_event:	Global event that is to be mapped to interrupt
576997b001fSLokesh Vutla  *			aggregator virtual interrupt status bit.
577997b001fSLokesh Vutla  * @vint_status_bit:	Virtual interrupt status bit if the interrupt route
578997b001fSLokesh Vutla  *			utilizes an interrupt aggregator status bit.
579997b001fSLokesh Vutla  * @secondary_host:	Host ID of the IRQ destination computing entity. This is
580997b001fSLokesh Vutla  *			required only when destination host id is different
581997b001fSLokesh Vutla  *			from ti sci interface host id.
582997b001fSLokesh Vutla  *
583997b001fSLokesh Vutla  * Request type is TI_SCI_MSG_SET/RELEASE_IRQ.
584997b001fSLokesh Vutla  * Response is generic ACK / NACK message.
585997b001fSLokesh Vutla  */
586997b001fSLokesh Vutla struct ti_sci_msg_req_manage_irq {
587997b001fSLokesh Vutla 	struct ti_sci_msg_hdr hdr;
588997b001fSLokesh Vutla #define MSG_FLAG_DST_ID_VALID			TI_SCI_MSG_FLAG(0)
589997b001fSLokesh Vutla #define MSG_FLAG_DST_HOST_IRQ_VALID		TI_SCI_MSG_FLAG(1)
590997b001fSLokesh Vutla #define MSG_FLAG_IA_ID_VALID			TI_SCI_MSG_FLAG(2)
591997b001fSLokesh Vutla #define MSG_FLAG_VINT_VALID			TI_SCI_MSG_FLAG(3)
592997b001fSLokesh Vutla #define MSG_FLAG_GLB_EVNT_VALID			TI_SCI_MSG_FLAG(4)
593997b001fSLokesh Vutla #define MSG_FLAG_VINT_STS_BIT_VALID		TI_SCI_MSG_FLAG(5)
594997b001fSLokesh Vutla #define MSG_FLAG_SHOST_VALID			TI_SCI_MSG_FLAG(31)
595997b001fSLokesh Vutla 	u32 valid_params;
596997b001fSLokesh Vutla 	u16 src_id;
597997b001fSLokesh Vutla 	u16 src_index;
598997b001fSLokesh Vutla 	u16 dst_id;
599997b001fSLokesh Vutla 	u16 dst_host_irq;
600997b001fSLokesh Vutla 	u16 ia_id;
601997b001fSLokesh Vutla 	u16 vint;
602997b001fSLokesh Vutla 	u16 global_event;
603997b001fSLokesh Vutla 	u8 vint_status_bit;
604997b001fSLokesh Vutla 	u8 secondary_host;
605997b001fSLokesh Vutla } __packed;
606997b001fSLokesh Vutla 
607aa276781SNishanth Menon #endif /* __TI_SCI_H */
608