OSDN Git Service

firmware: arm_scmi: Add notifications support in transport layer
authorCristian Marussi <cristian.marussi@arm.com>
Fri, 27 Mar 2020 14:34:28 +0000 (14:34 +0000)
committerSudeep Holla <sudeep.holla@arm.com>
Tue, 14 Apr 2020 08:31:49 +0000 (09:31 +0100)
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/20200327143438.5382-4-cristian.marussi@arm.com
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
drivers/firmware/arm_scmi/common.h
drivers/firmware/arm_scmi/mailbox.c
drivers/firmware/arm_scmi/shmem.c

index 34bfadc..07eb33c 100644 (file)
@@ -178,6 +178,8 @@ struct scmi_chan_info {
  * @send_message: Callback to send a message
  * @mark_txdone: Callback to mark tx as done
  * @fetch_response: Callback to fetch response
+ * @fetch_notification: Callback to fetch notification
+ * @clear_notification: Callback to clear a pending notification
  * @poll_done: Callback to poll transfer status
  */
 struct scmi_transport_ops {
@@ -190,6 +192,9 @@ struct scmi_transport_ops {
        void (*mark_txdone)(struct scmi_chan_info *cinfo, int ret);
        void (*fetch_response)(struct scmi_chan_info *cinfo,
                               struct scmi_xfer *xfer);
+       void (*fetch_notification)(struct scmi_chan_info *cinfo,
+                                  size_t max_len, struct scmi_xfer *xfer);
+       void (*clear_notification)(struct scmi_chan_info *cinfo);
        bool (*poll_done)(struct scmi_chan_info *cinfo, struct scmi_xfer *xfer);
 };
 
@@ -225,5 +230,8 @@ void shmem_tx_prepare(struct scmi_shared_mem __iomem *shmem,
 u32 shmem_read_header(struct scmi_shared_mem __iomem *shmem);
 void shmem_fetch_response(struct scmi_shared_mem __iomem *shmem,
                          struct scmi_xfer *xfer);
+void shmem_fetch_notification(struct scmi_shared_mem __iomem *shmem,
+                             size_t max_len, struct scmi_xfer *xfer);
+void shmem_clear_notification(struct scmi_shared_mem __iomem *shmem);
 bool shmem_poll_done(struct scmi_shared_mem __iomem *shmem,
                     struct scmi_xfer *xfer);
index 73077bb..19ee058 100644 (file)
@@ -158,6 +158,21 @@ static void mailbox_fetch_response(struct scmi_chan_info *cinfo,
        shmem_fetch_response(smbox->shmem, xfer);
 }
 
+static void mailbox_fetch_notification(struct scmi_chan_info *cinfo,
+                                      size_t max_len, struct scmi_xfer *xfer)
+{
+       struct scmi_mailbox *smbox = cinfo->transport_info;
+
+       shmem_fetch_notification(smbox->shmem, max_len, xfer);
+}
+
+static void mailbox_clear_notification(struct scmi_chan_info *cinfo)
+{
+       struct scmi_mailbox *smbox = cinfo->transport_info;
+
+       shmem_clear_notification(smbox->shmem);
+}
+
 static bool
 mailbox_poll_done(struct scmi_chan_info *cinfo, struct scmi_xfer *xfer)
 {
@@ -173,6 +188,8 @@ static struct scmi_transport_ops scmi_mailbox_ops = {
        .send_message = mailbox_send_message,
        .mark_txdone = mailbox_mark_txdone,
        .fetch_response = mailbox_fetch_response,
+       .fetch_notification = mailbox_fetch_notification,
+       .clear_notification = mailbox_clear_notification,
        .poll_done = mailbox_poll_done,
 };
 
index e1e816e..a5a5d0f 100644 (file)
@@ -67,6 +67,21 @@ void shmem_fetch_response(struct scmi_shared_mem __iomem *shmem,
        memcpy_fromio(xfer->rx.buf, shmem->msg_payload + 4, xfer->rx.len);
 }
 
+void shmem_fetch_notification(struct scmi_shared_mem __iomem *shmem,
+                             size_t max_len, struct scmi_xfer *xfer)
+{
+       /* Skip only the length of header in shmem area i.e 4 bytes */
+       xfer->rx.len = min_t(size_t, max_len, ioread32(&shmem->length) - 4);
+
+       /* Take a copy to the rx buffer.. */
+       memcpy_fromio(xfer->rx.buf, shmem->msg_payload, xfer->rx.len);
+}
+
+void shmem_clear_notification(struct scmi_shared_mem __iomem *shmem)
+{
+       iowrite32(SCMI_SHMEM_CHAN_STAT_CHANNEL_FREE, &shmem->channel_status);
+}
+
 bool shmem_poll_done(struct scmi_shared_mem __iomem *shmem,
                     struct scmi_xfer *xfer)
 {