Skip to content

Commit d5141f3

Browse files
cris-masudeep-holla
authored andcommitted
firmware: arm_scmi: Add notifications support in transport layer
Add common transport-layer methods to: - fetch a notification instead of a response - clear a pending notification Add also all the needed support in mailbox/shmem transports. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Jonathan Cameron <[email protected]> Reviewed-by: Viresh Kumar <[email protected]> Signed-off-by: Cristian Marussi <[email protected]> Signed-off-by: Sudeep Holla <[email protected]>
1 parent 2264417 commit d5141f3

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

drivers/firmware/arm_scmi/common.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ struct scmi_chan_info {
178178
* @send_message: Callback to send a message
179179
* @mark_txdone: Callback to mark tx as done
180180
* @fetch_response: Callback to fetch response
181+
* @fetch_notification: Callback to fetch notification
182+
* @clear_notification: Callback to clear a pending notification
181183
* @poll_done: Callback to poll transfer status
182184
*/
183185
struct scmi_transport_ops {
@@ -190,6 +192,9 @@ struct scmi_transport_ops {
190192
void (*mark_txdone)(struct scmi_chan_info *cinfo, int ret);
191193
void (*fetch_response)(struct scmi_chan_info *cinfo,
192194
struct scmi_xfer *xfer);
195+
void (*fetch_notification)(struct scmi_chan_info *cinfo,
196+
size_t max_len, struct scmi_xfer *xfer);
197+
void (*clear_notification)(struct scmi_chan_info *cinfo);
193198
bool (*poll_done)(struct scmi_chan_info *cinfo, struct scmi_xfer *xfer);
194199
};
195200

@@ -225,5 +230,8 @@ void shmem_tx_prepare(struct scmi_shared_mem __iomem *shmem,
225230
u32 shmem_read_header(struct scmi_shared_mem __iomem *shmem);
226231
void shmem_fetch_response(struct scmi_shared_mem __iomem *shmem,
227232
struct scmi_xfer *xfer);
233+
void shmem_fetch_notification(struct scmi_shared_mem __iomem *shmem,
234+
size_t max_len, struct scmi_xfer *xfer);
235+
void shmem_clear_notification(struct scmi_shared_mem __iomem *shmem);
228236
bool shmem_poll_done(struct scmi_shared_mem __iomem *shmem,
229237
struct scmi_xfer *xfer);

drivers/firmware/arm_scmi/mailbox.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,21 @@ static void mailbox_fetch_response(struct scmi_chan_info *cinfo,
158158
shmem_fetch_response(smbox->shmem, xfer);
159159
}
160160

161+
static void mailbox_fetch_notification(struct scmi_chan_info *cinfo,
162+
size_t max_len, struct scmi_xfer *xfer)
163+
{
164+
struct scmi_mailbox *smbox = cinfo->transport_info;
165+
166+
shmem_fetch_notification(smbox->shmem, max_len, xfer);
167+
}
168+
169+
static void mailbox_clear_notification(struct scmi_chan_info *cinfo)
170+
{
171+
struct scmi_mailbox *smbox = cinfo->transport_info;
172+
173+
shmem_clear_notification(smbox->shmem);
174+
}
175+
161176
static bool
162177
mailbox_poll_done(struct scmi_chan_info *cinfo, struct scmi_xfer *xfer)
163178
{
@@ -173,6 +188,8 @@ static struct scmi_transport_ops scmi_mailbox_ops = {
173188
.send_message = mailbox_send_message,
174189
.mark_txdone = mailbox_mark_txdone,
175190
.fetch_response = mailbox_fetch_response,
191+
.fetch_notification = mailbox_fetch_notification,
192+
.clear_notification = mailbox_clear_notification,
176193
.poll_done = mailbox_poll_done,
177194
};
178195

drivers/firmware/arm_scmi/shmem.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,21 @@ void shmem_fetch_response(struct scmi_shared_mem __iomem *shmem,
6767
memcpy_fromio(xfer->rx.buf, shmem->msg_payload + 4, xfer->rx.len);
6868
}
6969

70+
void shmem_fetch_notification(struct scmi_shared_mem __iomem *shmem,
71+
size_t max_len, struct scmi_xfer *xfer)
72+
{
73+
/* Skip only the length of header in shmem area i.e 4 bytes */
74+
xfer->rx.len = min_t(size_t, max_len, ioread32(&shmem->length) - 4);
75+
76+
/* Take a copy to the rx buffer.. */
77+
memcpy_fromio(xfer->rx.buf, shmem->msg_payload, xfer->rx.len);
78+
}
79+
80+
void shmem_clear_notification(struct scmi_shared_mem __iomem *shmem)
81+
{
82+
iowrite32(SCMI_SHMEM_CHAN_STAT_CHANNEL_FREE, &shmem->channel_status);
83+
}
84+
7085
bool shmem_poll_done(struct scmi_shared_mem __iomem *shmem,
7186
struct scmi_xfer *xfer)
7287
{

0 commit comments

Comments
 (0)