summaryrefslogtreecommitdiff
path: root/include/scmi_protocols.h
blob: a8fd0a5a729e9ec7fd550a0d1c526185624cc365 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
/*
 * Copyright (c) 2015-2019, Arm Limited and Contributors. All rights reserved.
 * Copyright (C) 2019-2020, Linaro Limited
 */
#ifndef _SCMI_PROTOCOLS_H
#define _SCMI_PROTOCOLS_H

#include <linux/bitops.h>
#include <asm/types.h>

/*
 * Subset the SCMI protocols definition
 * based on SCMI specification v2.0 (DEN0056B)
 * https://developer.arm.com/docs/den0056/b
 */

enum scmi_std_protocol {
	SCMI_PROTOCOL_ID_BASE = 0x10,
	SCMI_PROTOCOL_ID_POWER_DOMAIN = 0x11,
	SCMI_PROTOCOL_ID_SYSTEM = 0x12,
	SCMI_PROTOCOL_ID_PERF = 0x13,
	SCMI_PROTOCOL_ID_CLOCK = 0x14,
	SCMI_PROTOCOL_ID_SENSOR = 0x15,
	SCMI_PROTOCOL_ID_RESET_DOMAIN = 0x16,
	SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN = 0x17,
	SCMI_PROTOCOL_ID_PINCTRL = 0x19,
	SCMI_PROTOCOL_ID_VENDOR_80 = 0x80,
	SCMI_PROTOCOL_ID_VENDOR_82 = 0x82,
};

enum scmi_status_code {
	SCMI_SUCCESS =  0,
	SCMI_NOT_SUPPORTED = -1,
	SCMI_INVALID_PARAMETERS = -2,
	SCMI_DENIED = -3,
	SCMI_NOT_FOUND = -4,
	SCMI_OUT_OF_RANGE = -5,
	SCMI_BUSY = -6,
	SCMI_COMMS_ERROR = -7,
	SCMI_GENERIC_ERROR = -8,
	SCMI_HARDWARE_ERROR = -9,
	SCMI_PROTOCOL_ERROR = -10,
	SCMI_IN_USE = -11,
};

/*
 * Generic message IDs
 */
enum scmi_discovery_id {
	SCMI_PROTOCOL_VERSION = 0x0,
	SCMI_PROTOCOL_ATTRIBUTES = 0x1,
	SCMI_PROTOCOL_MESSAGE_ATTRIBUTES = 0x2,
};

enum scmi_imx_misc_message_id {
	SCMI_MISC_ROM_PASSOVER_GET = 0x7,
	SCMI_MISC_DDR_INFO_GET = 0x22,
};

/*
 * SCMI Base Protocol
 */
#define SCMI_BASE_PROTOCOL_VERSION 0x20000

enum scmi_base_message_id {
	SCMI_BASE_DISCOVER_VENDOR = 0x3,
	SCMI_BASE_DISCOVER_SUB_VENDOR = 0x4,
	SCMI_BASE_DISCOVER_IMPL_VERSION = 0x5,
	SCMI_BASE_DISCOVER_LIST_PROTOCOLS = 0x6,
	SCMI_BASE_DISCOVER_AGENT = 0x7,
	SCMI_BASE_NOTIFY_ERRORS = 0x8,
	SCMI_BASE_SET_DEVICE_PERMISSIONS = 0x9,
	SCMI_BASE_SET_PROTOCOL_PERMISSIONS = 0xa,
	SCMI_BASE_RESET_AGENT_CONFIGURATION = 0xb,
};

#define SCMI_BASE_NAME_LENGTH_MAX 16

/**
 * struct scmi_protocol_version_out - Response for SCMI_PROTOCOL_VERSION
 *					command
 * @status:	SCMI command status
 * @version:	Protocol version
 */
struct scmi_protocol_version_out {
	s32 status;
	u32 version;
};

/**
 * struct scmi_protocol_attrs_out - Response for SCMI_PROTOCOL_ATTRIBUTES
 *					command
 * @status:	SCMI command status
 * @attributes:	Protocol attributes or implementation details
 */
struct scmi_protocol_attrs_out {
	s32 status;
	u32 attributes;
};

#define SCMI_PROTOCOL_ATTRS_NUM_AGENTS(attributes) \
				(((attributes) & GENMASK(15, 8)) >> 8)
#define SCMI_PROTOCOL_ATTRS_NUM_PROTOCOLS(attributes) \
				((attributes) & GENMASK(7, 0))

/**
 * struct scmi_protocol_msg_attrs_out - Response for
 *					SCMI_PROTOCOL_MESSAGE_ATTRIBUTES command
 * @status:	SCMI command status
 * @attributes:	Message-specific attributes
 */
struct scmi_protocol_msg_attrs_out {
	s32 status;
	u32 attributes;
};

/**
 * struct scmi_base_discover_vendor_out - Response for
 *					  SCMI_BASE_DISCOVER_VENDOR or
 *					  SCMI_BASE_DISCOVER_SUB_VENDOR command
 * @status:		SCMI command status
 * @vendor_identifier:	Name of vendor or sub-vendor in string
 */
struct scmi_base_discover_vendor_out {
	s32 status;
	u8 vendor_identifier[SCMI_BASE_NAME_LENGTH_MAX];
};

/**
 * struct scmi_base_discover_impl_version_out - Response for
 *					SCMI_BASE_DISCOVER_IMPL_VERSION command
 * @status:		SCMI command status
 * @impl_version:	Vendor-specific implementation version
 */
struct scmi_base_discover_impl_version_out {
	s32 status;
	u32 impl_version;
};

/**
 * struct scmi_base_discover_list_protocols_out - Response for
 *				SCMI_BASE_DISCOVER_LIST_PROTOCOLS command
 * @status:		SCMI command status
 * @num_protocols:	Number of SCMI protocols in @protocol
 * @protocols:		Array of packed SCMI protocol ID's
 */
struct scmi_base_discover_list_protocols_out {
	s32 status;
	u32 num_protocols;
	u32 protocols[];
};

/**
 * struct scmi_base_discover_agent_out - Response for
 *					 SCMI_BASE_DISCOVER_AGENT command
 * @status:	SCMI command status
 * @agent_id:	SCMI agent ID
 * @name:	Name of agent in string
 */
struct scmi_base_discover_agent_out {
	s32 status;
	u32 agent_id;
	u8 name[SCMI_BASE_NAME_LENGTH_MAX];
};

#define SCMI_BASE_NOTIFY_ERRORS_ENABLE BIT(0)

/**
 * struct scmi_base_set_device_permissions_in - Parameters for
 *					SCMI_BASE_SET_DEVICE_PERMISSIONS command
 * @agent_id:	SCMI agent ID
 * @device_id:	device ID
 * @flags:	A set of flags
 */
struct scmi_base_set_device_permissions_in {
	u32 agent_id;
	u32 device_id;
	u32 flags;
};

#define SCMI_BASE_SET_DEVICE_PERMISSIONS_ACCESS BIT(0)

/**
 * struct scmi_base_set_protocol_permissions_in - Parameters for
 *				SCMI_BASE_SET_PROTOCOL_PERMISSIONS command
 * @agent_id:		SCMI agent ID
 * @device_id:		device ID
 * @command_id:		command ID
 * @flags:		A set of flags
 */
struct scmi_base_set_protocol_permissions_in {
	u32 agent_id;
	u32 device_id;
	u32 command_id;
	u32 flags;
};

#define SCMI_BASE_SET_PROTOCOL_PERMISSIONS_COMMAND GENMASK(7, 0)
#define SCMI_BASE_SET_PROTOCOL_PERMISSIONS_ACCESS BIT(0)

/**
 * struct scmi_base_reset_agent_configuration_in - Parameters for
 *				SCMI_BASE_RESET_AGENT_CONFIGURATION command
 * @agent_id:	SCMI agent ID
 * @flags:	A set of flags
 */
struct scmi_base_reset_agent_configuration_in {
	u32 agent_id;
	u32 flags;
};

#define SCMI_BASE_RESET_ALL_ACCESS_PERMISSIONS BIT(0)

/**
 * struct scmi_base_ops - SCMI base protocol interfaces
 */
struct scmi_base_ops {
	/**
	 * protocol_version - get Base protocol version
	 * @dev:	SCMI protocol device
	 * @version:	Pointer to SCMI protocol version
	 *
	 * Obtain the protocol version number in @version for Base protocol.
	 *
	 * Return: 0 on success, error code on failure
	 */
	int (*protocol_version)(struct udevice *dev, u32 *version);
	/**
	 * protocol_attrs - get protocol attributes
	 * @dev:		SCMI protocol device
	 * @num_agents:		Number of SCMI agents
	 * @num_protocols:	Number of SCMI protocols
	 *
	 * Obtain the protocol attributes, the number of agents and the number
	 * of protocols, in @num_agents and @num_protocols respectively, that
	 * the device provides.
	 *
	 * Return: 0 on success, error code on failure
	 */
	int (*protocol_attrs)(struct udevice *dev, u32 *num_agents,
			      u32 *num_protocols);
	/**
	 * protocol_message_attrs - get message-specific attributes
	 * @dev:		SCMI protocol device
	 * @message_id:		SCMI message ID
	 * @attributes:		Message-specific attributes
	 *
	 * Obtain the message-specific attributes in @attributes.
	 * This command succeeds if the message is implemented and available.
	 *
	 * Return: 0 on success, error code on failure
	 */
	int (*protocol_message_attrs)(struct udevice *dev, u32 message_id,
				      u32 *attributes);
	/**
	 * base_discover_vendor - get vendor name
	 * @dev:	SCMI protocol device
	 * @vendor:	Pointer to vendor name
	 *
	 * Obtain the vendor's name in @vendor.
	 * It is a caller's responsibility to free @vendor.
	 *
	 * Return: 0 on success, error code on failure
	 */
	int (*base_discover_vendor)(struct udevice *dev, u8 **vendor);
	/**
	 * base_discover_sub_vendor - get sub-vendor name
	 * @dev:	SCMI protocol device
	 * @sub_vendor:	Pointer to sub-vendor name
	 *
	 * Obtain the sub-vendor's name in @sub_vendor.
	 * It is a caller's responsibility to free @sub_vendor.
	 *
	 * Return: 0 on success, error code on failure
	 */
	int (*base_discover_sub_vendor)(struct udevice *dev, u8 **sub_vendor);
	/**
	 * base_discover_impl_version - get implementation version
	 * @dev:		SCMI protocol device
	 * @impl_version:	Pointer to implementation version
	 *
	 * Obtain the implementation version number in @impl_version.
	 *
	 * Return: 0 on success, error code on failure
	 */
	int (*base_discover_impl_version)(struct udevice *dev,
					  u32 *impl_version);
	/**
	 * base_discover_list_protocols - get list of protocols
	 * @dev:	SCMI protocol device
	 * @protocols:	Pointer to array of SCMI protocols
	 *
	 * Obtain the list of protocols provided in @protocols.
	 * The number of elements in @protocols always match to the number of
	 * protocols returned by smci_protocol_attrs() when this function
	 * succeeds.
	 * It is a caller's responsibility to free @protocols.
	 *
	 * Return: the number of protocols in @protocols on success,
	 * error code on failure
	 */
	int (*base_discover_list_protocols)(struct udevice *dev,
					    u8 **protocols);
	/**
	 * base_discover_agent - identify agent
	 * @dev:		SCMI protocol device
	 * @agent_id:		SCMI agent ID
	 * @ret_agent_id:	Pointer to SCMI agent ID
	 * @name:		Pointer to SCMI agent name
	 *
	 * Obtain the agent's name in @name. If @agent_id is equal to
	 * 0xffffffff, * this function returns the caller's agent id in
	 * @ret_agent_id.
	 * It is a caller's responsibility to free @name.
	 *
	 * Return: 0 on success, error code on failure
	 */
	int (*base_discover_agent)(struct udevice *dev, u32 agent_id,
				   u32 *ret_agent_id, u8 **name);
	/**
	 * base_notify_errors - configure error notification
	 * @dev:	SCMI protocol device
	 * @enable:	Operation
	 *
	 * Enable or disable error notification from SCMI firmware.
	 *
	 * Return: 0 on success, error code on failure
	 */
	int (*base_notify_errors)(struct udevice *dev, u32 enable);
	/**
	 * base_set_device_permissions - configure access permission to device
	 * @dev:	SCMI protocol device
	 * @agent_id:	SCMI agent ID
	 * @device_id:	ID of device to access
	 * @flags:	A set of flags
	 *
	 * Ask for allowing or denying access permission to the device,
	 * @device_id. The meaning of @flags is defined in SCMI specification.
	 *
	 * Return: 0 on success, error code on failure
	 */
	int (*base_set_device_permissions)(struct udevice *dev, u32 agent_id,
					   u32 device_id, u32 flags);
	/**
	 * base_set_protocol_permissions - configure access permission to
	 *				   protocol on device
	 * @dev:	SCMI protocol device
	 * @agent_id:	SCMI agent ID
	 * @device_id:	ID of device to access
	 * @command_id:	command ID
	 * @flags:	A set of flags
	 *
	 * Ask for allowing or denying access permission to the protocol,
	 * @command_id, on the device, @device_id.
	 * The meaning of @flags is defined in SCMI specification.
	 *
	 * Return: 0 on success, error code on failure
	 */
	int (*base_set_protocol_permissions)(struct udevice *dev, u32 agent_id,
					     u32 device_id, u32 command_id,
					     u32 flags);
	/**
	 * base_reset_agent_configuration - reset resource settings
	 * @dev:	SCMI protocol device
	 * @agent_id:	SCMI agent ID
	 * @flags:	A set of flags
	 *
	 * Reset all the resource settings against @agent_id.
	 * The meaning of @flags is defined in SCMI specification.
	 *
	 * Return: 0 on success, error code on failure
	 */
	int (*base_reset_agent_configuration)(struct udevice *dev, u32 agent_id,
					      u32 flags);
};

/**
 * scmi_generic_protocol_version - get protocol version
 * @dev:	SCMI protocol device
 * @id:		SCMI protocol ID
 * @version:	Pointer to SCMI protocol version
 *
 * Obtain the protocol version number in @version.
 *
 * Return: 0 on success, error code on failure
 */
int scmi_generic_protocol_version(struct udevice *dev,
				  enum scmi_std_protocol id, u32 *version);

/**
 * scmi_base_protocol_version - get Base protocol version
 * @dev:	SCMI protocol device
 * @version:	Pointer to SCMI protocol version
 *
 * Obtain the protocol version number in @version for Base protocol.
 *
 * Return: 0 on success, error code on failure
 */
int scmi_base_protocol_version(struct udevice *dev, u32 *version);

/**
 * scmi_base_protocol_attrs - get protocol attributes
 * @dev:		SCMI protocol device
 * @num_agents:		Number of SCMI agents
 * @num_protocols:	Number of SCMI protocols
 *
 * Obtain the protocol attributes, the number of agents and the number
 * of protocols, in @num_agents and @num_protocols respectively, that
 * the device provides.
 *
 * Return: 0 on success, error code on failure
 */
int scmi_base_protocol_attrs(struct udevice *dev, u32 *num_agents,
			     u32 *num_protocols);

/**
 * scmi_base_protocol_message_attrs - get message-specific attributes
 * @dev:		SCMI protocol device
 * @message_id:		SCMI message ID
 * @attributes:		Message-specific attributes
 *
 * Obtain the message-specific attributes in @attributes.
 * This command succeeds if the message is implemented and available.
 *
 * Return: 0 on success, error code on failure
 */
int scmi_base_protocol_message_attrs(struct udevice *dev, u32 message_id,
				     u32 *attributes);

/**
 * scmi_base_discover_vendor - get vendor name
 * @dev:	SCMI protocol device
 * @vendor:	Pointer to vendor name
 *
 * Obtain the vendor's name in @vendor.
 * It is a caller's responsibility to free @vendor.
 *
 * Return: 0 on success, error code on failure
 */
int scmi_base_discover_vendor(struct udevice *dev, u8 **vendor);

/**
 * scmi_base_discover_sub_vendor - get sub-vendor name
 * @dev:	SCMI protocol device
 * @sub_vendor:	Pointer to sub-vendor name
 *
 * Obtain the sub-vendor's name in @sub_vendor.
 * It is a caller's responsibility to free @sub_vendor.
 *
 * Return: 0 on success, error code on failure
 */
int scmi_base_discover_sub_vendor(struct udevice *dev, u8 **sub_vendor);

/**
 * scmi_base_discover_impl_version - get implementation version
 * @dev:		SCMI protocol device
 * @impl_version:	Pointer to implementation version
 *
 * Obtain the implementation version number in @impl_version.
 *
 * Return: 0 on success, error code on failure
 */
int scmi_base_discover_impl_version(struct udevice *dev, u32 *impl_version);

/**
 * scmi_base_discover_list_protocols - get list of protocols
 * @dev:	SCMI protocol device
 * @protocols:	Pointer to array of SCMI protocols
 *
 * Obtain the list of protocols provided in @protocols.
 * The number of elements in @protocols always match to the number of
 * protocols returned by smci_protocol_attrs() when this function succeeds.
 * It is a caller's responsibility to free @protocols.
 *
 * Return: the number of protocols in @protocols on success, error code on
 * failure
 */
int scmi_base_discover_list_protocols(struct udevice *dev, u8 **protocols);

/**
 * scmi_base_discover_agent - identify agent
 * @dev:		SCMI protocol device
 * @agent_id:		SCMI agent ID
 * @ret_agent_id:	Pointer to SCMI agent ID
 * @name:		Pointer to SCMI agent name
 *
 * Obtain the agent's name in @name. If @agent_id is equal to 0xffffffff,
 * this function returns the caller's agent id in @ret_agent_id.
 * It is a caller's responsibility to free @name.
 *
 * Return: 0 on success, error code on failure
 */
int scmi_base_discover_agent(struct udevice *dev, u32 agent_id,
			     u32 *ret_agent_id, u8 **name);

/**
 * scmi_base_notify_errors - configure error notification
 * @dev:	SCMI protocol device
 * @enable:	Operation
 *
 * Enable or disable error notification from SCMI firmware.
 *
 * Return: 0 on success, error code on failure
 */
int scmi_base_notify_errors(struct udevice *dev, u32 enable);

/**
 * scmi_base_set_device_permissions - configure access permission to device
 * @dev:	SCMI protocol device
 * @agent_id:	SCMI agent ID
 * @device_id:	ID of device to access
 * @flags:	A set of flags
 *
 * Ask for allowing or denying access permission to the device, @device_id.
 * The meaning of @flags is defined in SCMI specification.
 *
 * Return: 0 on success, error code on failure
 */
int scmi_base_set_device_permissions(struct udevice *dev, u32 agent_id,
				     u32 device_id, u32 flags);

/**
 * scmi_base_set_protocol_permissions - configure access permission to
 *					protocol on device
 * @dev:	SCMI protocol device
 * @agent_id:	SCMI agent ID
 * @device_id:	ID of device to access
 * @command_id:	SCMI command ID
 * @flags:	A set of flags
 *
 * Ask for allowing or denying access permission to the protocol, @command_id,
 * on the device, @device_id.
 * The meaning of @flags is defined in SCMI specification.
 *
 * Return: 0 on success, error code on failure
 */
int scmi_base_set_protocol_permissions(struct udevice *dev,
				       u32 agent_id, u32 device_id,
				       u32 command_id, u32 flags);

/**
 * scmi_base_reset_agent_configuration - reset resource settings
 * @dev:	SCMI protocol device
 * @agent_id:	SCMI agent ID
 * @flags:	A set of flags
 *
 * Reset all the resource settings against @agent_id.
 * The meaning of @flags is defined in SCMI specification.
 *
 * Return: 0 on success, error code on failure
 */
int scmi_base_reset_agent_configuration(struct udevice *dev, u32 agent_id,
					u32 flags);

/*
 * SCMI Power Domain Management Protocol
 */

#define SCMI_PWD_PROTOCOL_VERSION 0x30000
#define SCMI_PWD_PSTATE_TYPE_LOST BIT(30)
#define SCMI_PWD_PSTATE_ID GENMASK(27, 0)

enum scmi_power_domain_message_id {
	SCMI_PWD_ATTRIBUTES = 0x3,
	SCMI_PWD_STATE_SET = 0x4,
	SCMI_PWD_STATE_GET = 0x5,
	SCMI_PWD_STATE_NOTIFY = 0x6,
	SCMI_PWD_STATE_CHANGE_REQUESTED_NOTIFY = 0x7,
	SCMI_PWD_NAME_GET = 0x8,
};

/**
 * struct scmi_pwd_protocol_attrs_out
 * @status:		SCMI command status
 * @attributes:		Protocol attributes
 * @stats_addr_low:	Lower 32 bits of address of statistics memory region
 * @stats_addr_high:	Higher 32 bits of address of statistics memory region
 * @stats_len:		Length of statistics memory region
 */
struct scmi_pwd_protocol_attrs_out {
	s32 status;
	u32 attributes;
	u32 stats_addr_low;
	u32 stats_addr_high;
	u32 stats_len;
};

#define SCMI_PWD_PROTO_ATTRS_NUM_PWD(attributes) ((attributes) & GENMASK(15, 0))

/**
 * struct scmi_pwd_protocol_msg_attrs_out
 * @status:		SCMI command status
 * @attributes:		Message-specific attributes
 */
struct scmi_pwd_protocol_msg_attrs_out {
	s32 status;
	u32 attributes;
};

#define SCMI_PWD_NAME_LENGTH_MAX 16

/**
 * struct scmi_pwd_attrs_out
 * @status:	SCMI command status
 * @attributes:	Power domain attributes
 * @name:	Name of power domain
 */
struct scmi_pwd_attrs_out {
	s32 status;
	u32 attributes;
	u8 name[SCMI_PWD_NAME_LENGTH_MAX];
};

#define SCMI_PWD_ATTR_PSTATE_CHANGE_NOTIFY	BIT(31)
#define SCMI_PWD_ATTR_PSTATE_ASYNC		BIT(30)
#define SCMI_PWD_ATTR_PSTATE_SYNC		BIT(29)
#define SCMI_PWD_ATTR_PSTATE_CHANGE_RQ_NOTIFY	BIT(28)
#define SCMI_PWD_ATTR_EXTENDED_NAME		BIT(27)

/**
 * struct scmi_pwd_state_set_in
 * @flags:	Flags
 * @domain_id:	Identifier of power domain
 * @pstate:	Power state of the domain
 */
struct scmi_pwd_state_set_in {
	u32 flags;
	u32 domain_id;
	u32 pstate;
};

#define SCMI_PWD_SET_FLAGS_ASYNC BIT(0)

/**
 * struct scmi_pwd_state_get_out
 * @status:	SCMI command status
 * @pstate:	Power state of the domain
 */
struct scmi_pwd_state_get_out {
	s32 status;
	u32 pstate;
};

#define SCMI_PWD_EXTENDED_NAME_MAX 64
/**
 * struct scmi_pwd_name_get_out
 * @status:		SCMI command status
 * @flags:		Parameter flags
 * @extended_name:	Extended name of power domain
 */
struct scmi_pwd_name_get_out {
	s32 status;
	u32 flags;
	u8 extended_name[SCMI_PWD_EXTENDED_NAME_MAX];
};

/**
 * scmi_pwd_protocol_attrs - get protocol attributes
 * @dev:	SCMI protocol device
 * @num_pwdoms:	Number of power domains
 * @stats_addr:	Address of statistics memory region
 * @stats_len:	Length of statistics memory region
 *
 * Obtain the protocol attributes, the number of power domains and
 * the information of statistics memory region.
 *
 * Return: 0 on success, error code on failure
 */
int scmi_pwd_protocol_attrs(struct udevice *dev, int *num_pwdoms,
			    u64 *stats_addr, size_t *stats_len);
/**
 * scmi_pwd_protocol_message_attrs - get message-specific attributes
 * @dev:		SCMI protocol device
 * @message_id:		SCMI message ID
 * @attributes:		Message-specific attributes
 *
 * Obtain the message-specific attributes in @attributes.
 *
 * Return: 0 on success, error code on failure
 */
int scmi_pwd_protocol_message_attrs(struct udevice *dev, s32 message_id,
				    u32 *attributes);
/**
 * scmi_pwd_attrs - get power domain attributes
 * @dev:	SCMI protocol device
 * @domain_id:	Identifier of power domain
 * @attributes:	Power domain attributes
 * @name:	Name of power domain
 *
 * Obtain the attributes of the given power domain, @domain_id, in @attributes
 * as well as its name in @name.
 *
 * Return: 0 on success, error code on failure
 */
int scmi_pwd_attrs(struct udevice *dev, u32 message_id, u32 *attributes,
		   u8 **name);
/**
 * scmi_pwd_state_set - set power state
 * @dev:	SCMI protocol device
 * @flags:	Parameter flags
 * @domain_id:	Identifier of power domain
 * @pstate:	Power state
 *
 * Change the power state of the given power domain, @domain_id.
 *
 * Return: 0 on success, error code on failure
 */
int scmi_pwd_state_set(struct udevice *dev, u32 flags, u32 domain_id,
		       u32 pstate);
/**
 * scmi_pwd_state_get - get power state
 * @dev:	SCMI protocol device
 * @domain_id:	Identifier of power domain
 * @pstate:	Power state
 *
 * Obtain the power state of the given power domain, @domain_id.
 *
 * Return: 0 on success, error code on failure
 */
int scmi_pwd_state_get(struct udevice *dev, u32 domain_id, u32 *pstate);
/**
 * scmi_pwd_name_get - get extended name
 * @dev:	SCMI protocol device
 * @domain_id:	Identifier of power domain
 * @name:	Extended name of the domain
 *
 * Obtain the extended name of the given power domain, @domain_id, in @name.
 *
 * Return: 0 on success, error code on failure
 */
int scmi_pwd_name_get(struct udevice *dev, u32 domain_id, u8 **name);

/*
 * SCMI Clock Protocol
 */
#define CLOCK_PROTOCOL_VERSION_2_1	0x20001
#define CLOCK_PROTOCOL_VERSION_3_0	0x30000

enum scmi_clock_message_id {
	SCMI_CLOCK_ATTRIBUTES = 0x3,
	SCMI_CLOCK_RATE_SET = 0x5,
	SCMI_CLOCK_RATE_GET = 0x6,
	SCMI_CLOCK_CONFIG_SET = 0x7,
	SCMI_CLOCK_PARENT_SET = 0xD,
	SCMI_CLOCK_GET_PERMISSIONS = 0xF,
};

#define SCMI_CLK_PROTO_ATTR_COUNT_MASK	GENMASK(15, 0)
#define SCMI_CLK_RATE_ASYNC_NOTIFY	BIT(0)
#define SCMI_CLK_RATE_ASYNC_NORESP	(BIT(0) | BIT(1))
#define SCMI_CLK_RATE_ROUND_DOWN	0
#define SCMI_CLK_RATE_ROUND_UP		BIT(2)
#define SCMI_CLK_RATE_ROUND_CLOSEST	BIT(3)

#define SCMI_CLOCK_NAME_LENGTH_MAX 16

/**
 * struct scmi_clk_protocol_attr_out - Response for SCMI_PROTOCOL_ATTRIBUTES command
 * @status:	SCMI command status
 * @attributes:	Attributes of the clock protocol, mainly number of clocks exposed
 */
struct scmi_clk_protocol_attr_out {
	s32 status;
	u32 attributes;
};

/**
 * struct scmi_clk_attribute_in - Message payload for SCMI_CLOCK_ATTRIBUTES command
 * @clock_id:	SCMI clock ID
 */
struct scmi_clk_attribute_in {
	u32 clock_id;
};

/**
 * struct scmi_clk_attribute_out - Response payload for SCMI_CLOCK_ATTRIBUTES command
 * @status:	SCMI command status
 * @attributes:	clock attributes
 * @clock_name:	name of the clock
 */
struct scmi_clk_attribute_out {
	s32 status;
	u32 attributes;
#define CLK_HAS_RESTRICTIONS(x)	((x) & BIT(1))
	char clock_name[SCMI_CLOCK_NAME_LENGTH_MAX];
};

/**
 * struct scmi_clk_attribute_out_v2 - Response payload for SCMI_CLOCK_ATTRIBUTES command
 * Clock management Protocol 2.0
 * @status:	SCMI command status
 * @attributes:	clock attributes
 * @clock_name:	name of the clock
 * @clock_enable_delay: delay incurred by the platform to enable the clock
 */
struct scmi_clk_attribute_out_v2 {
	s32 status;
	u32 attributes;
	char clock_name[SCMI_CLOCK_NAME_LENGTH_MAX];
	u32 clock_enable_delay;
};

/**
 * struct scmi_clk_state_in_v1 - Message payload for CLOCK_CONFIG_SET command for protocol < 2.1
 * @clock_id:	SCMI clock ID
 * @attributes:	Attributes of the targets clock state
 */
struct scmi_clk_state_in_v1 {
	u32 clock_id;
	u32 attributes;
};

/**
 * struct scmi_clk_state_in_v2 - Message payload for CLOCK_CONFIG_SET command for protocol >= 2.1
 * @clock_id:	SCMI clock ID
 * @attributes:	Attributes of the targets clock state
 * @extended_config_val: Extended and OEM specific configuration
 */
struct scmi_clk_state_in_v2 {
	u32 clock_id;
	u32 attributes;
	u32 extended_config_val;
};

/**
 * struct scmi_clk_state_out - Response payload for CLOCK_CONFIG_SET command
 * @status:	SCMI command status
 */
struct scmi_clk_state_out {
	s32 status;
};

/**
 * struct scmi_clk_rate_get_in - Message payload for CLOCK_RATE_GET command
 * @clock_id:	SCMI clock ID
 * @attributes:	Attributes of the targets clock state
 */
struct scmi_clk_rate_get_in {
	u32 clock_id;
};

/**
 * struct scmi_clk_rate_get_out - Response payload for CLOCK_RATE_GET command
 * @status:	SCMI command status
 * @rate_lsb:	32bit LSB of the clock rate in Hertz
 * @rate_msb:	32bit MSB of the clock rate in Hertz
 */
struct scmi_clk_rate_get_out {
	s32 status;
	u32 rate_lsb;
	u32 rate_msb;
};

/**
 * struct scmi_clk_rate_set_in - Message payload for CLOCK_RATE_SET command
 * @flags:	Flags for the clock rate set request
 * @clock_id:	SCMI clock ID
 * @rate_lsb:	32bit LSB of the clock rate in Hertz
 * @rate_msb:	32bit MSB of the clock rate in Hertz
 */
struct scmi_clk_rate_set_in {
	u32 flags;
	u32 clock_id;
	u32 rate_lsb;
	u32 rate_msb;
};

/**
 * struct scmi_clk_rate_set_out - Response payload for CLOCK_RATE_SET command
 * @status:	SCMI command status
 */
struct scmi_clk_rate_set_out {
	s32 status;
};

/**
 * struct scmi_clk_parent_set_in - Message payload for CLOCK_PARENT_SET command
 * @clock_id:		SCMI clock ID
 * @parent_clk:		SCMI clock ID
 */
struct scmi_clk_parent_set_in {
	u32 clock_id;
	u32 parent_clk;
};

/**
 * struct scmi_clk_parent_set_out - Response payload for CLOCK_PARENT_SET command
 * @status:	SCMI command status
 */
struct scmi_clk_parent_set_out {
	s32 status;
};

/**
 * struct scmi_clk_get_permissions_in - Message payload for CLOCK_GET_PERMISSIONS command
 * @clock_id:	Identifier for the clock device.
 */
struct scmi_clk_get_permissions_in {
	u32 clock_id;
};

/**
 * struct scmi_clk_get_permissions_out - Response payload for CLOCK_GET_PERMISSIONS command
 * @status:	Negative 32-bit integers are used to return error status codes.
 * @permissions:	Bit[31] Clock state control, Bit[30] Clock parent control,
 * Bit[29] Clock rate control, Bits[28:0] Reserved, must be zero.
 */
struct scmi_clk_get_permissions_out {
	s32 status;
	u32 permissions;
};

#define SUPPORT_CLK_STAT_CONTROL	BIT(31)
#define SUPPORT_CLK_PARENT_CONTROL	BIT(30)
#define SUPPORT_CLK_RATE_CONTROL	BIT(29)

/*
 * SCMI Reset Domain Protocol
 */

enum scmi_reset_domain_message_id {
	SCMI_RESET_DOMAIN_ATTRIBUTES = 0x3,
	SCMI_RESET_DOMAIN_RESET = 0x4,
};

#define SCMI_RD_NAME_LEN		16

#define SCMI_RD_ATTRIBUTES_FLAG_ASYNC	BIT(31)
#define SCMI_RD_ATTRIBUTES_FLAG_NOTIF	BIT(30)

#define SCMI_RD_RESET_FLAG_ASYNC	BIT(2)
#define SCMI_RD_RESET_FLAG_ASSERT	BIT(1)
#define SCMI_RD_RESET_FLAG_CYCLE	BIT(0)

/**
 * struct scmi_rd_attr_in - Payload for RESET_DOMAIN_ATTRIBUTES message
 * @domain_id:	SCMI reset domain ID
 */
struct scmi_rd_attr_in {
	u32 domain_id;
};

/**
 * struct scmi_rd_attr_out - Payload for RESET_DOMAIN_ATTRIBUTES response
 * @status:	SCMI command status
 * @attributes:	Retrieved attributes of the reset domain
 * @latency:	Reset cycle max lantency
 * @name:	Reset domain name
 */
struct scmi_rd_attr_out {
	s32 status;
	u32 attributes;
	u32 latency;
	char name[SCMI_RD_NAME_LEN];
};

/**
 * struct scmi_rd_reset_in - Message payload for RESET command
 * @domain_id:		SCMI reset domain ID
 * @flags:		Flags for the reset request
 * @reset_state:	Reset target state
 */
struct scmi_rd_reset_in {
	u32 domain_id;
	u32 flags;
	u32 reset_state;
};

/**
 * struct scmi_rd_reset_out - Response payload for RESET command
 * @status:	SCMI command status
 */
struct scmi_rd_reset_out {
	s32 status;
};

/*
 * SCMI Voltage Domain Protocol
 */

enum scmi_voltage_domain_message_id {
	SCMI_VOLTAGE_DOMAIN_ATTRIBUTES = 0x3,
	SCMI_VOLTAGE_DOMAIN_CONFIG_SET = 0x5,
	SCMI_VOLTAGE_DOMAIN_CONFIG_GET = 0x6,
	SCMI_VOLTAGE_DOMAIN_LEVEL_SET = 0x7,
	SCMI_VOLTAGE_DOMAIN_LEVEL_GET = 0x8,
};

#define SCMI_VOLTD_NAME_LEN		16

#define SCMI_VOLTD_CONFIG_MASK		GENMASK(3, 0)
#define SCMI_VOLTD_CONFIG_OFF		0
#define SCMI_VOLTD_CONFIG_ON		0x7

/**
 * struct scmi_voltd_attr_in - Payload for VOLTAGE_DOMAIN_ATTRIBUTES message
 * @domain_id:	SCMI voltage domain ID
 */
struct scmi_voltd_attr_in {
	u32 domain_id;
};

/**
 * struct scmi_voltd_attr_out - Payload for VOLTAGE_DOMAIN_ATTRIBUTES response
 * @status:	SCMI command status
 * @attributes:	Retrieved attributes of the voltage domain
 * @name:	Voltage domain name
 */
struct scmi_voltd_attr_out {
	s32 status;
	u32 attributes;
	char name[SCMI_VOLTD_NAME_LEN];
};

/**
 * struct scmi_voltd_config_set_in - Message payload for VOLTAGE_CONFIG_SET cmd
 * @domain_id:	SCMI voltage domain ID
 * @config:	Configuration data of the voltage domain
 */
struct scmi_voltd_config_set_in {
	u32 domain_id;
	u32 config;
};

/**
 * struct scmi_voltd_config_set_out - Response for VOLTAGE_CONFIG_SET command
 * @status:	SCMI command status
 */
struct scmi_voltd_config_set_out {
	s32 status;
};

/**
 * struct scmi_voltd_config_get_in - Message payload for VOLTAGE_CONFIG_GET cmd
 * @domain_id:	SCMI voltage domain ID
 */
struct scmi_voltd_config_get_in {
	u32 domain_id;
};

/**
 * struct scmi_voltd_config_get_out - Response for VOLTAGE_CONFIG_GET command
 * @status:	SCMI command status
 * @config:	Configuration data of the voltage domain
 */
struct scmi_voltd_config_get_out {
	s32 status;
	u32 config;
};

/**
 * struct scmi_voltd_level_set_in - Message payload for VOLTAGE_LEVEL_SET cmd
 * @domain_id:		SCMI voltage domain ID
 * @flags:		Parameter flags for configuring target level
 * @voltage_level:	Target voltage level in microvolts (uV)
 */
struct scmi_voltd_level_set_in {
	u32 domain_id;
	u32 flags;
	s32 voltage_level;
};

/**
 * struct scmi_voltd_level_set_out - Response for VOLTAGE_LEVEL_SET command
 * @status:	SCMI	command status
 */
struct scmi_voltd_level_set_out {
	s32 status;
};

/**
 * struct scmi_voltd_level_get_in - Message payload for VOLTAGE_LEVEL_GET cmd
 * @domain_id:		SCMI voltage domain ID
 */
struct scmi_voltd_level_get_in {
	u32 domain_id;
};

/**
 * struct scmi_voltd_level_get_out - Response for VOLTAGE_LEVEL_GET command
 * @status:		SCMI command status
 * @voltage_level:	Voltage level in microvolts (uV)
 */
struct scmi_voltd_level_get_out {
	s32 status;
	s32 voltage_level;
};

/* SCMI Pinctrl Protocol */
enum scmi_pinctrl_message_id {
	SCMI_PINCTRL_ATTRIBUTES = 0x3,
	SCMI_PINCTRL_LIST_ASSOCIATIONS = 0x4,
	SCMI_PINCTRL_SETTINGS_GET = 0x5,
	SCMI_PINCTRL_SETTINGS_CONFIGURE = 0x6,
	SCMI_PINCTRL_REQUEST = 0x7,
	SCMI_PINCTRL_RELEASE = 0x8,
	SCMI_PINCTRL_NAME_GET = 0x9,
	SCMI_PINCTRL_SET_PERMISSIONS = 0xA,
};

struct scmi_pin_config {
	u32 type;
	u32 val;
};

/**
 * struct scmi_pinctrl_config_set_in - Message payload for PAD_CONFIG_SET command
 * @identifier:		Identifier for the pin or group.
 * @function_id:	Identifier for the function selected to be enabled
 *			for the selected pin or group. This field is set to
 *			0xFFFFFFFF if no function should be enabled by the
 *			pin or group.
 * @attributes:		Bits[31:11] Reserved, must be zero.
 *			Bit[10] Function valid.
 *			Bits[9:2] Number of configurations to set.
 *			Bits[1:0] Selector: Whether the identifier field
 *				  refers to a pin or a group.
 * @configs:	Array of configurations.
 */
struct scmi_pinctrl_config_set_in {
	u32 identifier;
	u32 function_id;
	u32 attributes;
	struct scmi_pin_config configs[4];
};

struct scmi_pinctrl_config_set_out {
	s32 status;
};

/* SCMI Perf Protocol */
enum scmi_perf_message_id {
	SCMI_PERF_DOMAIN_ATTRIBUTES = 0x3,
	SCMI_PERF_DESCRIBE_LEVELS = 0x4,
	SCMI_PERF_LIMITS_SET = 0x5,
	SCMI_PERF_LIMITS_GET = 0x6,
	SCMI_PERF_LEVEL_SET = 0x7,
	SCMI_PERF_LEVEL_GET = 0x8
};

struct scmi_perf_in {
	u32 domain_id;
	u32 perf_level;
};

struct scmi_perf_out {
	s32 status;
};

#define SCMI_PIN_NAME_LEN 16

struct pin_info {
	char name[SCMI_PIN_NAME_LEN];
};

struct group_info {
	char name[SCMI_PIN_NAME_LEN];
	u16 *pins;
	u32 num_pins;
};

struct function_info {
	char name[SCMI_PIN_NAME_LEN];
	u16 *groups;
	u32 num_groups;
};

/* This is used by both the SCMI pinctrl and gpio drivers */
struct pinctrl_scmi_priv {
	int num_pins;
	struct pin_info *pin_info;
	int num_groups;
	struct group_info *group_info;
	int num_functions;
	struct function_info *function_info;
};

/* SCMI Pinctrl selector type */
enum select_type {
	SCMI_PIN,
	SCMI_GROUP,
	SCMI_FUNCTION,
};

/**
 * struct scmi_pinctrl_protocol_attrs_out - Response to SCMI_PROTOCOL_ATTRIBUTES
 *					command.
 * @status:	SCMI command status
 * @attr_low:	Number of pins and groups
 * @attr_high:	Number of functions
 */
struct scmi_pinctrl_protocol_attrs_out {
	s32 status;
	u32 attr_low;
	u32 attr_high;
};

/**
 * struct scmi_pinctrl_attrs_in - Parameters for SCMI_PINCTRL_ATTRIBUTES command
 * @id:			Identifier for pin, group or function
 * @select_type:	Pin, group or function
 */
struct scmi_pinctrl_attrs_in {
	u32 id;
	u32 select_type;
};

/**
 * struct scmi_pinctrl_attrs_out - Response to SCMI_PINCTRL_ATTRIBUTES command
 * @status:	SCMI command status
 * @attr:	GPIO, number of pins or groups
 * @name:	Name of pin, group or function
 */
struct scmi_pinctrl_attrs_out {
	s32 status;
	u32 attr;
	u8 name[SCMI_PIN_NAME_LEN];
};

/**
 * struct scmi_pinctrl_list_associations_in - Parameters for
 *					SCMI_PINCTRL_LIST_ASSOCIATIONS command
 * @id:			Identifier for group or function
 * @select_type:	Group or function
 * @index:		Index within the group or function
 */
struct scmi_pinctrl_list_associations_in {
	u32 id;
	u32 select_type;
	u32 index;
};

/**
 * struct scmi_pinctrl_list_associations_out - Response to
 *					SCMI_PINCTRL_LIST_ASSOCIATIONS command
 * @status:	SCMI command status
 * @flags:	Number of items returned and number still remaining
 * @array:	List of groups or pins
 */
struct scmi_pinctrl_list_associations_out {
	s32 status;
	u32 flags;
	u16 array[];
};

/**
 * struct scmi_pinctrl_settings_get_in - Parameters for
 *					SCMI_PINCTRL_SETTINGS_GET command
 * @id:		Identifier for pin or group
 * @attr:	Config flag: one setting, function or all settings
 *		Selector: Pin or Group
 *		Skip: Number of config types to skip
 *		Config type: Type of config to read
 */
struct scmi_pinctrl_settings_get_in {
	u32 id;
	u32 attr;
};

#define SCMI_PINCTRL_CONFIG_SETTINGS_ALL -2u  /* This is an internal magic number */
#define SCMI_PINCTRL_FUNCTION_NONE 0xFFFFFFFF

/**
 * struct scmi_pinctrl_settings_get_out - Response to SCMI_PINCTRL_SETTINGS_GET
 *					command
 * @status:		SCMI command status
 * @function_selected:	The function enabled by the pin or group
 * @num_configs:	The number of settings returned and number still remaining
 * @configs:		The list of config data
 */
struct scmi_pinctrl_settings_get_out {
	s32 status;
	u32 function_selected;
	u32 num_configs;
	u32 configs[];
};

/**
 * struct scmi_pinctrl_settings_configure_in - Parameters for
 *					SCMI_PINCTRL_SETTINGS_CONFIGURE command
 * @id:			Identifier for pin or group
 * @function_id:	The function to enable for this pin or group (optional)
 * @attr:		Function id: Set the function or not
 *			Number of configs to set
 *			Selector: pin or group
 * @configs:		List of config type value pairs
 */
struct scmi_pinctrl_settings_configure_in {
	u32 id;
	u32 function_id;
	u32 attr;
	u32 configs[];
};

/**
 * struct scmi_pinctrl_settings_configure_out - Response to
 *					SCMI_PINCTRL_SETTINGS_CONFIGURE command
 * @status:	SCMI command status
 */
struct scmi_pinctrl_settings_configure_out {
	s32 status;
};

/**
 * struct scmi_pinctrl_request_in - Parameters for SCMI_PINCTRL_REQUEST command
 * @id:		Identifier for pin or group
 * @flags:	Pin, group or function
 */
struct scmi_pinctrl_request_in {
	u32 id;
	u32 flags;
};

/**
 * struct scmi_pinctrl_request_out - Response to SCMI_PINCTRL_REQUEST command
 * @status:	SCMI command status
 */
struct scmi_pinctrl_request_out {
	s32 status;
};

/**
 * struct scmi_pinctrl_release_in - Parameters for SCMI_PINCTRL_RELEASE command
 * @id:		Identifier for pin or group
 * @flags:	Pin, group or function
 */
struct scmi_pinctrl_release_in {
	u32 id;
	u32 flags;
};

/**
 * struct scmi_pinctrl_release_out - Response to SCMI_PINCTRL_RELEASE command
 * @status:	SCMI command status
 */
struct scmi_pinctrl_release_out {
	s32 status;
};

/* SCMI Pinctrl Config Types */
enum scmi_config_type {
	SCMI_PIN_DEFUALT = 0,
	SCMI_PIN_BIAS_BUS_HOLD = 1,
	SCMI_PIN_BIAS_DISABLE = 2,
	SCMI_PIN_BIAS_HIGH_IMPEDANCE = 3,
	SCMI_PIN_BIAS_PULL_UP = 4,
	SCMI_PIN_BIAS_PULL_DEFAULT = 5,
	SCMI_PIN_BIAS_PULL_DOWN = 6,
	SCMI_PIN_DRIVE_OPEN_DRAIN = 7,
	SCMI_PIN_DRIVE_OPEN_SOURCE = 8,
	SCMI_PIN_DRIVE_PUSH_PULL = 9,
	SCMI_PIN_DRIVE_STRENGTH = 10,
	SCMI_PIN_INPUT_DEBOUNCE = 11,
	SCMI_PIN_INPUT_MODE = 12,
	SCMI_PIN_PULL_MODE = 13,
	SCMI_PIN_INPUT_VALUE = 14,
	SCMI_PIN_INPUT_SCHMITT = 15,
	SCMI_PIN_LOW_POWER_MODE = 16,
	SCMI_PIN_OUTPUT_MODE = 17,
	SCMI_PIN_OUTPUT_VALUE = 18,
	SCMI_PIN_POWER_SOURCE = 19,
	SCMI_PIN_SLEW_RATE = 20,
};

/**
 * scmi_pinctrl_protocol_attrs - get pinctrl information
 * @dev: SCMI protocol device
 * @num_pins: Number of pins
 * @num_groups: Number of groups
 * @num_functions: Number of functions
 *
 * Obtain the number of pins, groups and functions.
 *
 * Return: 0 on success, error code on failure
 */
int scmi_pinctrl_protocol_attrs(struct udevice *dev, int *num_pins,
				int *num_groups, int *num_functions);

/**
 * scmi_pinctrl_attrs - get information for a specific pin, group or function
 * @dev: SCMI protocol device
 * @select_type: pin, group or function
 * @selector: id of pin, group or function
 * @gpio: set to true if the pin or group supports gpio
 * @count: number of groups in function or pins in group
 * @name: name of pin, group or function
 *
 * Obtain information about a specific pin, group or function.
 *
 * Return: 0 on success, error code on failure
 */
int scmi_pinctrl_attrs(struct udevice *dev, enum select_type select_type,
		       unsigned int selector, bool *gpio, unsigned int *count,
		       char *name);

/**
 * scmi_pinctrl_request - claim a pin or group
 * @dev: SCMI protocol device
 * @select_type: pin or group
 * @selector: id of pin or group
 *
 * Claim ownership of a pin or group.
 *
 * Return: 0 on success, error code on failure
 */
int scmi_pinctrl_request(struct udevice *dev, enum select_type select_type,
			 unsigned int selector);
/**
 * scmi_pinctrl_release - release a claimed pin or group
 * @dev: SCMI protocol device
 * @select_type: pin or group
 * @selector: id of pin or group
 *
 * Release a pin or group that you previously claimed.
 *
 * Return: 0 on success, error code on failure
 */
int scmi_pinctrl_release(struct udevice *dev, enum select_type select_type,
			 unsigned int selector);

/**
 * scmi_pinctrl_list_associations - get list of pins in group or groups in function
 * @dev: SCMI protocol device
 * @select_type: group or function
 * @selector: id of group or function
 * @output: list of groups in function or pins in group
 * @num_out: How many groups are in the function or pins in the group
 *
 * Obtain the list of groups or pins in the function or group respectively.
 * We know how many items will be in the list from calling scmi_pinctrl_attrs().
 *
 * Return: 0 on success, error code on failure
 */
int scmi_pinctrl_list_associations(struct udevice *dev,
				   enum select_type select_type,
				   unsigned int selector,
				   unsigned short *output,
				   unsigned short num_out);

/**
 * scmi_pinctrl_settings_get_one - get a configuration setting
 * @dev: SCMI protocol device
 * @select_type: pin or group
 * @selector: id of pin or group
 * @config_type: Which configuration type to read
 * @value: returned configuration value
 *
 * This reads a single config setting.  Most importantly the
 * SCMI_PIN_INPUT_VALUE setting is used to read from a pin.
 *
 * Return: 0 on success, error code on failure
 */
int scmi_pinctrl_settings_get_one(struct udevice *dev, enum select_type select_type,
				  unsigned int selector,
				  u32 config_type, u32 *value);

/**
 * scmi_pinctrl_settings_configure - set multiple configuration settings
 * @dev: SCMI protocol device
 * @select_type: pin or group
 * @selector: id of pin or group
 * @num_configs: number of settings to set
 * @configs: Config type and value pairs
 *
 * Configure multiple settings at once to reduce overhead.  The
 * SCMI_PIN_OUTPUT_VALUE setting is used to write to a pin.
 *
 * Return: 0 on success, error code on failure
 */
int scmi_pinctrl_settings_configure(struct udevice *dev, enum select_type select_type,
				    unsigned int selector, u16 num_configs,
				    u32 *configs);

/**
 * scmi_pinctrl_settings_configure_one - set a configuration setting
 * @dev: SCMI protocol device
 * @select_type: pin or group
 * @selector: id of pin or group
 * @param: The setting type to configure
 * @argument: The value of the configuration
 *
 * Configure a single setting.  The SCMI_PIN_OUTPUT_VALUE setting is used to
 * write to a pin.
 *
 * Return: 0 on success, error code on failure
 */
int scmi_pinctrl_settings_configure_one(struct udevice *dev, enum select_type select_type,
					unsigned int selector,
					u32 param, u32 argument);

/**
 * scmi_pinctrl_set_function - set the function for a group or pin
 * @dev: SCMI protocol device
 * @select_type: pin or group
 * @selector: id of pin or group
 * @function_id: id of the function
 *
 * Set the function for a group or pin.
 *
 * Return: 0 on success, error code on failure
 */
int scmi_pinctrl_set_function(struct udevice *dev, enum select_type select_type,
			      unsigned int selector, u32 function_id);

#endif /* _SCMI_PROTOCOLS_H */