Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
| 2 | /* |
| 3 | * Copyright (C) 2019-2020 Linaro Limited. |
| 4 | */ |
| 5 | #ifndef _SCMI_AGENT_UCLASS_H |
| 6 | #define _SCMI_AGENT_UCLASS_H |
| 7 | |
AKASHI Takahiro | 410be2c | 2023-10-11 19:07:04 +0900 | [diff] [blame^] | 8 | #include <scmi_protocols.h> |
AKASHI Takahiro | 6c90f82 | 2023-10-11 19:06:58 +0900 | [diff] [blame] | 9 | #include <dm/device.h> |
| 10 | |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 11 | struct scmi_msg; |
Etienne Carriere | 0544029 | 2022-05-31 18:09:19 +0200 | [diff] [blame] | 12 | struct scmi_channel; |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 13 | |
| 14 | /** |
AKASHI Takahiro | 6c90f82 | 2023-10-11 19:06:58 +0900 | [diff] [blame] | 15 | * struct scmi_agent_priv - private data maintained by agent instance |
AKASHI Takahiro | 410be2c | 2023-10-11 19:07:04 +0900 | [diff] [blame^] | 16 | * @version: Version |
| 17 | * @num_agents: Number of agents |
| 18 | * @num_protocols: Number of protocols |
| 19 | * @impl_version: Implementation version |
| 20 | * @protocols: Array of protocol IDs |
| 21 | * @vendor: Vendor name |
| 22 | * @sub_vendor: Sub-vendor name |
| 23 | * @agent_name: Agent name |
| 24 | * @agent_id: Identifier of agent |
| 25 | * @base_dev: SCMI base protocol device |
AKASHI Takahiro | 6c90f82 | 2023-10-11 19:06:58 +0900 | [diff] [blame] | 26 | * @clock_dev: SCMI clock protocol device |
| 27 | * @resetdom_dev: SCMI reset domain protocol device |
| 28 | * @voltagedom_dev: SCMI voltage domain protocol device |
| 29 | */ |
| 30 | struct scmi_agent_priv { |
AKASHI Takahiro | 410be2c | 2023-10-11 19:07:04 +0900 | [diff] [blame^] | 31 | u32 version; |
| 32 | u32 num_agents; |
| 33 | u32 num_protocols; |
| 34 | u32 impl_version; |
| 35 | u8 *protocols; |
| 36 | u8 *vendor; |
| 37 | u8 *sub_vendor; |
| 38 | u8 *agent_name; |
| 39 | u32 agent_id; |
| 40 | struct udevice *base_dev; |
AKASHI Takahiro | 6c90f82 | 2023-10-11 19:06:58 +0900 | [diff] [blame] | 41 | struct udevice *clock_dev; |
| 42 | struct udevice *resetdom_dev; |
| 43 | struct udevice *voltagedom_dev; |
| 44 | }; |
| 45 | |
AKASHI Takahiro | 410be2c | 2023-10-11 19:07:04 +0900 | [diff] [blame^] | 46 | static inline u32 scmi_version(struct udevice *dev) |
| 47 | { |
| 48 | return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->version; |
| 49 | } |
| 50 | |
| 51 | static inline u32 scmi_num_agents(struct udevice *dev) |
| 52 | { |
| 53 | return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->num_agents; |
| 54 | } |
| 55 | |
| 56 | static inline u32 scmi_num_protocols(struct udevice *dev) |
| 57 | { |
| 58 | return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->num_protocols; |
| 59 | } |
| 60 | |
| 61 | static inline u32 scmi_impl_version(struct udevice *dev) |
| 62 | { |
| 63 | return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->impl_version; |
| 64 | } |
| 65 | |
| 66 | static inline u8 *scmi_protocols(struct udevice *dev) |
| 67 | { |
| 68 | return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->protocols; |
| 69 | } |
| 70 | |
| 71 | static inline u8 *scmi_vendor(struct udevice *dev) |
| 72 | { |
| 73 | return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->vendor; |
| 74 | } |
| 75 | |
| 76 | static inline u8 *scmi_sub_vendor(struct udevice *dev) |
| 77 | { |
| 78 | return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->sub_vendor; |
| 79 | } |
| 80 | |
| 81 | static inline u8 *scmi_agent_name(struct udevice *dev) |
| 82 | { |
| 83 | return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->agent_name; |
| 84 | } |
| 85 | |
| 86 | static inline u32 scmi_agent_id(struct udevice *dev) |
| 87 | { |
| 88 | return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->agent_id; |
| 89 | } |
| 90 | |
AKASHI Takahiro | 6c90f82 | 2023-10-11 19:06:58 +0900 | [diff] [blame] | 91 | /** |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 92 | * struct scmi_transport_ops - The functions that a SCMI transport layer must implement. |
| 93 | */ |
| 94 | struct scmi_agent_ops { |
| 95 | /* |
Etienne Carriere | 187cea1 | 2022-05-31 18:09:21 +0200 | [diff] [blame] | 96 | * of_get_channel - Get SCMI channel from SCMI agent device tree node |
| 97 | * |
AKASHI Takahiro | 589ec9a | 2023-10-11 19:06:55 +0900 | [diff] [blame] | 98 | * @dev: SCMI agent device using the transport |
| 99 | * @protocol: SCMI protocol device using the transport |
Etienne Carriere | 187cea1 | 2022-05-31 18:09:21 +0200 | [diff] [blame] | 100 | * @channel: Output reference to SCMI channel upon success |
| 101 | * Return 0 upon success and a negative errno on failure |
| 102 | */ |
AKASHI Takahiro | 589ec9a | 2023-10-11 19:06:55 +0900 | [diff] [blame] | 103 | int (*of_get_channel)(struct udevice *dev, struct udevice *protocol, |
| 104 | struct scmi_channel **channel); |
Etienne Carriere | 187cea1 | 2022-05-31 18:09:21 +0200 | [diff] [blame] | 105 | |
| 106 | /* |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 107 | * process_msg - Request transport to get the SCMI message processed |
| 108 | * |
AKASHI Takahiro | 589ec9a | 2023-10-11 19:06:55 +0900 | [diff] [blame] | 109 | * @dev: SCMI agent device using the transport |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 110 | * @msg: SCMI message to be transmitted |
| 111 | */ |
Etienne Carriere | 0544029 | 2022-05-31 18:09:19 +0200 | [diff] [blame] | 112 | int (*process_msg)(struct udevice *dev, struct scmi_channel *channel, |
| 113 | struct scmi_msg *msg); |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 114 | }; |
| 115 | |
| 116 | #endif /* _SCMI_TRANSPORT_UCLASS_H */ |