blob: dd88f646ed69c066d194fcd90b862b5eae28ca0a [file] [log] [blame]
Lokesh Vutla5af02db2018-08-27 15:57:32 +05301/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * Texas Instruments System Control Interface Protocol
4 * Based on include/linux/soc/ti/ti_sci_protocol.h from Linux.
5 *
6 * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
7 * Nishanth Menon
8 * Lokesh Vutla <lokeshvutla@ti.com>
9 */
10
11#ifndef __TISCI_PROTOCOL_H
12#define __TISCI_PROTOCOL_H
13
14/**
15 * struct ti_sci_version_info - version information structure
16 * @abi_major: Major ABI version. Change here implies risk of backward
17 * compatibility break.
18 * @abi_minor: Minor ABI version. Change here implies new feature addition,
19 * or compatible change in ABI.
20 * @firmware_revision: Firmware revision (not usually used).
21 * @firmware_description: Firmware description (not usually used).
22 */
23struct ti_sci_version_info {
24 u8 abi_major;
25 u8 abi_minor;
26 u16 firmware_revision;
27 char firmware_description[32];
28};
29
30struct ti_sci_handle;
31
32/**
Andreas Dannenberg5299c4c2018-08-27 15:57:33 +053033 * struct ti_sci_board_ops - Board config operations
34 * @board_config: Command to set the board configuration
35 * Returns 0 for successful exclusive request, else returns
36 * corresponding error message.
37 * @board_config_rm: Command to set the board resource management
38 * configuration
39 * Returns 0 for successful exclusive request, else returns
40 * corresponding error message.
41 * @board_config_security: Command to set the board security configuration
42 * Returns 0 for successful exclusive request, else returns
43 * corresponding error message.
44 * @board_config_pm: Command to trigger and set the board power and clock
45 * management related configuration
46 * Returns 0 for successful exclusive request, else returns
47 * corresponding error message.
48 */
49struct ti_sci_board_ops {
50 int (*board_config)(const struct ti_sci_handle *handle,
51 u64 addr, u32 size);
52 int (*board_config_rm)(const struct ti_sci_handle *handle,
53 u64 addr, u32 size);
54 int (*board_config_security)(const struct ti_sci_handle *handle,
55 u64 addr, u32 size);
56 int (*board_config_pm)(const struct ti_sci_handle *handle,
57 u64 addr, u32 size);
58};
59
60/**
61 * struct ti_sci_ops - Function support for TI SCI
62 * @board_ops: Miscellaneous operations
63 */
64struct ti_sci_ops {
65 struct ti_sci_board_ops board_ops;
66};
67
68/**
Lokesh Vutla5af02db2018-08-27 15:57:32 +053069 * struct ti_sci_handle - Handle returned to TI SCI clients for usage.
Andreas Dannenberg5299c4c2018-08-27 15:57:33 +053070 * @ops: operations that are made available to TI SCI clients
Lokesh Vutla5af02db2018-08-27 15:57:32 +053071 * @version: structure containing version information
72 */
73struct ti_sci_handle {
Andreas Dannenberg5299c4c2018-08-27 15:57:33 +053074 struct ti_sci_ops ops;
Lokesh Vutla5af02db2018-08-27 15:57:32 +053075 struct ti_sci_version_info version;
76};
77
78#if IS_ENABLED(CONFIG_TI_SCI_PROTOCOL)
79
80const struct ti_sci_handle *ti_sci_get_handle_from_sysfw(struct udevice *dev);
81const struct ti_sci_handle *ti_sci_get_handle(struct udevice *dev);
82const struct ti_sci_handle *ti_sci_get_by_phandle(struct udevice *dev,
83 const char *property);
84
85#else /* CONFIG_TI_SCI_PROTOCOL */
86
87static inline
88const struct ti_sci_handle *ti_sci_get_handle_from_sysfw(struct udevice *dev)
89{
90 return ERR_PTR(-EINVAL);
91}
92
93static inline const struct ti_sci_handle *ti_sci_get_handle(struct udevice *dev)
94{
95 return ERR_PTR(-EINVAL);
96}
97
98static inline
99const struct ti_sci_handle *ti_sci_get_by_phandle(struct udevice *dev,
100 const char *property)
101{
102 return ERR_PTR(-EINVAL);
103}
104#endif /* CONFIG_TI_SCI_PROTOCOL */
105
106#endif /* __TISCI_PROTOCOL_H */