1 From 9d5366d4765fb60cafa31c2b46cd80d284c847bb Mon Sep 17 00:00:00 2001
2 From: Peter Hilber <peter.hilber@opensynergy.com>
3 Date: Thu, 5 Nov 2020 22:21:13 +0100
4 Subject: [PATCH] firmware: arm_scmi: Add per-device transport private info
6 The scmi-virtio transport will link a supplier device to the arm-scmi
7 device in the link_supplier() op. The transport should then save a
8 pointer to the linked device.
10 To enable this, add a transport private info to the scmi_info. (The
11 scmi_info is already reachable through the arm-scmi device driver_data.)
13 Signed-off-by: Peter Hilber <peter.hilber@opensynergy.com>
14 Signed-off-by: Vasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
16 drivers/firmware/arm_scmi/common.h | 2 ++
17 drivers/firmware/arm_scmi/driver.c | 35 ++++++++++++++++++++++++++++++
18 2 files changed, 37 insertions(+)
20 diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h
21 index 2f55ac71555a..ec9fd7fce3c7 100644
22 --- a/drivers/firmware/arm_scmi/common.h
23 +++ b/drivers/firmware/arm_scmi/common.h
24 @@ -262,6 +262,8 @@ extern const struct scmi_desc scmi_mailbox_desc;
25 extern const struct scmi_desc scmi_smc_desc;
28 +int scmi_set_transport_info(struct device *dev, void *transport_info);
29 +void *scmi_get_transport_info(struct device *dev);
30 void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr);
31 void scmi_free_channel(struct scmi_chan_info *cinfo, struct idr *idr, int id);
33 diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
34 index 0b70f9ef9477..93ce17bb4079 100644
35 --- a/drivers/firmware/arm_scmi/driver.c
36 +++ b/drivers/firmware/arm_scmi/driver.c
37 @@ -84,6 +84,7 @@ struct scmi_xfers_info {
38 * @rx_idr: IDR object to map protocol id to Rx channel info pointer
39 * @protocols_imp: List of protocols implemented, currently maximum of
40 * MAX_PROTOCOLS_IMP elements allocated by the base protocol
41 + * @transport_info: Transport private info
43 * @users: Number of users of this instance
45 @@ -97,6 +98,7 @@ struct scmi_info {
49 + void *transport_info;
50 struct list_head node;
53 @@ -315,6 +317,39 @@ void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr)
58 + * scmi_set_transport_info() - Set transport private info
60 + * @dev: SCMI instance device
61 + * @transport_info: transport private info
63 + * Return: 0 on success, otherwise error.
65 +int scmi_set_transport_info(struct device *dev, void *transport_info)
67 + struct scmi_info *info = dev_get_drvdata(dev);
72 + info->transport_info = transport_info;
77 + * scmi_get_transport_info() - Get transport private info
79 + * @dev: SCMI instance device
81 + * Return: transport private info on success, otherwise NULL.
83 +void *scmi_get_transport_info(struct device *dev)
85 + struct scmi_info *info = dev_get_drvdata(dev);
87 + return info ? info->transport_info : NULL;
91 * scmi_xfer_put() - Release a transmit message