0025-firmware-ti_sci-rm-Add-new-ops-for-ring-configuratio.patch 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. From db5dded64c9de553bed288acc9cacc8d49b5ea97 Mon Sep 17 00:00:00 2001
  2. From: Peter Ujfalusi <peter.ujfalusi@ti.com>
  3. Date: Sun, 25 Oct 2020 12:10:06 -0700
  4. Subject: [PATCH] firmware: ti_sci: rm: Add new ops for ring configuration
  5. The sysfw ring configuration message has been extended to include virtid
  6. and asel value for the ring.
  7. Add the ASEL_VALID to TI_SCI_MSG_VALUE_RM_ALL_NO_ORDER as it is required
  8. for DMA rings.
  9. Instead of extending the current .config() ops - which would need same
  10. patch change in the ringacc driver - add ti_sci_msg_rm_ring_cfg struct and
  11. a new ops using it to configure the ring.
  12. This will allow easy update path in case new members are added for the ring
  13. configuration.
  14. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
  15. Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
  16. Signed-off-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
  17. ---
  18. drivers/firmware/ti_sci.c | 63 ++++++++++++++++++++++++++
  19. drivers/firmware/ti_sci.h | 7 +++
  20. include/linux/soc/ti/ti_sci_protocol.h | 31 ++++++++++++-
  21. 3 files changed, 100 insertions(+), 1 deletion(-)
  22. diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
  23. index 0b801e67e672..a4d2b318795c 100644
  24. --- a/drivers/firmware/ti_sci.c
  25. +++ b/drivers/firmware/ti_sci.c
  26. @@ -2119,6 +2119,68 @@ static int ti_sci_cmd_ring_config(const struct ti_sci_handle *handle,
  27. return ret;
  28. }
  29. +/**
  30. + * ti_sci_cmd_rm_ring_cfg() - Configure a NAVSS ring
  31. + * @handle: Pointer to TI SCI handle.
  32. + * @params: Pointer to ti_sci_msg_rm_ring_cfg ring config structure
  33. + *
  34. + * Return: 0 if all went well, else returns appropriate error value.
  35. + *
  36. + * See @ti_sci_msg_rm_ring_cfg and @ti_sci_msg_rm_ring_cfg_req for
  37. + * more info.
  38. + */
  39. +static int ti_sci_cmd_rm_ring_cfg(const struct ti_sci_handle *handle,
  40. + const struct ti_sci_msg_rm_ring_cfg *params)
  41. +{
  42. + struct ti_sci_msg_rm_ring_cfg_req *req;
  43. + struct ti_sci_msg_hdr *resp;
  44. + struct ti_sci_xfer *xfer;
  45. + struct ti_sci_info *info;
  46. + struct device *dev;
  47. + int ret = 0;
  48. +
  49. + if (IS_ERR_OR_NULL(handle))
  50. + return -EINVAL;
  51. +
  52. + info = handle_to_ti_sci_info(handle);
  53. + dev = info->dev;
  54. +
  55. + xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_RM_RING_CFG,
  56. + TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
  57. + sizeof(*req), sizeof(*resp));
  58. + if (IS_ERR(xfer)) {
  59. + ret = PTR_ERR(xfer);
  60. + dev_err(dev, "RM_RA:Message config failed(%d)\n", ret);
  61. + return ret;
  62. + }
  63. + req = (struct ti_sci_msg_rm_ring_cfg_req *)xfer->xfer_buf;
  64. + req->valid_params = params->valid_params;
  65. + req->nav_id = params->nav_id;
  66. + req->index = params->index;
  67. + req->addr_lo = params->addr_lo;
  68. + req->addr_hi = params->addr_hi;
  69. + req->count = params->count;
  70. + req->mode = params->mode;
  71. + req->size = params->size;
  72. + req->order_id = params->order_id;
  73. + req->virtid = params->virtid;
  74. + req->asel = params->asel;
  75. +
  76. + ret = ti_sci_do_xfer(info, xfer);
  77. + if (ret) {
  78. + dev_err(dev, "RM_RA:Mbox config send fail %d\n", ret);
  79. + goto fail;
  80. + }
  81. +
  82. + resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf;
  83. + ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL;
  84. +
  85. +fail:
  86. + ti_sci_put_one_xfer(&info->minfo, xfer);
  87. + dev_dbg(dev, "RM_RA:config ring %u ret:%d\n", params->index, ret);
  88. + return ret;
  89. +}
  90. +
  91. /**
  92. * ti_sci_cmd_rm_psil_pair() - Pair PSI-L source to destination thread
  93. * @handle: Pointer to TI SCI handle.
  94. @@ -2847,6 +2909,7 @@ static void ti_sci_setup_ops(struct ti_sci_info *info)
  95. iops->free_event_map = ti_sci_cmd_free_event_map;
  96. rops->config = ti_sci_cmd_ring_config;
  97. + rops->set_cfg = ti_sci_cmd_rm_ring_cfg;
  98. psilops->pair = ti_sci_cmd_rm_psil_pair;
  99. psilops->unpair = ti_sci_cmd_rm_psil_unpair;
  100. diff --git a/drivers/firmware/ti_sci.h b/drivers/firmware/ti_sci.h
  101. index 1cdf918be861..ef3a8214d002 100644
  102. --- a/drivers/firmware/ti_sci.h
  103. +++ b/drivers/firmware/ti_sci.h
  104. @@ -659,6 +659,8 @@ struct ti_sci_msg_req_manage_irq {
  105. * 3 - Valid bit for @tisci_msg_rm_ring_cfg_req mode
  106. * 4 - Valid bit for @tisci_msg_rm_ring_cfg_req size
  107. * 5 - Valid bit for @tisci_msg_rm_ring_cfg_req order_id
  108. + * 6 - Valid bit for @tisci_msg_rm_ring_cfg_req virtid
  109. + * 7 - Valid bit for @tisci_msg_rm_ring_cfg_req ASEL
  110. * @nav_id: Device ID of Navigator Subsystem from which the ring is allocated
  111. * @index: ring index to be configured.
  112. * @addr_lo: 32 LSBs of ring base address to be programmed into the ring's
  113. @@ -672,6 +674,9 @@ struct ti_sci_msg_req_manage_irq {
  114. * the formula (log2(size_bytes) - 2), where size_bytes cannot be
  115. * greater than 256.
  116. * @order_id: Specifies the ring's bus order ID.
  117. + * @virtid: Ring virt ID value
  118. + * @asel: Ring ASEL (address select) value to be set into the ASEL field of the
  119. + * ring's RING_BA_HI register.
  120. */
  121. struct ti_sci_msg_rm_ring_cfg_req {
  122. struct ti_sci_msg_hdr hdr;
  123. @@ -684,6 +689,8 @@ struct ti_sci_msg_rm_ring_cfg_req {
  124. u8 mode;
  125. u8 size;
  126. u8 order_id;
  127. + u16 virtid;
  128. + u8 asel;
  129. } __packed;
  130. /**
  131. diff --git a/include/linux/soc/ti/ti_sci_protocol.h b/include/linux/soc/ti/ti_sci_protocol.h
  132. index 7727ec954f62..d7f0dcf98861 100644
  133. --- a/include/linux/soc/ti/ti_sci_protocol.h
  134. +++ b/include/linux/soc/ti/ti_sci_protocol.h
  135. @@ -275,17 +275,44 @@ struct ti_sci_rm_irq_ops {
  136. #define TI_SCI_MSG_VALUE_RM_RING_SIZE_VALID BIT(4)
  137. /* RA config.order_id parameter is valid for RM ring configure TISCI message */
  138. #define TI_SCI_MSG_VALUE_RM_RING_ORDER_ID_VALID BIT(5)
  139. +/* RA config.virtid parameter is valid for RM ring configure TISCI message */
  140. +#define TI_SCI_MSG_VALUE_RM_RING_VIRTID_VALID BIT(6)
  141. +/* RA config.asel parameter is valid for RM ring configure TISCI message */
  142. +#define TI_SCI_MSG_VALUE_RM_RING_ASEL_VALID BIT(7)
  143. #define TI_SCI_MSG_VALUE_RM_ALL_NO_ORDER \
  144. (TI_SCI_MSG_VALUE_RM_RING_ADDR_LO_VALID | \
  145. TI_SCI_MSG_VALUE_RM_RING_ADDR_HI_VALID | \
  146. TI_SCI_MSG_VALUE_RM_RING_COUNT_VALID | \
  147. TI_SCI_MSG_VALUE_RM_RING_MODE_VALID | \
  148. - TI_SCI_MSG_VALUE_RM_RING_SIZE_VALID)
  149. + TI_SCI_MSG_VALUE_RM_RING_SIZE_VALID | \
  150. + TI_SCI_MSG_VALUE_RM_RING_ASEL_VALID)
  151. +
  152. +/**
  153. + * struct ti_sci_msg_rm_ring_cfg - Ring configuration
  154. + *
  155. + * Parameters for Navigator Subsystem ring configuration
  156. + * See @ti_sci_msg_rm_ring_cfg_req
  157. + */
  158. +struct ti_sci_msg_rm_ring_cfg {
  159. + u32 valid_params;
  160. + u16 nav_id;
  161. + u16 index;
  162. + u32 addr_lo;
  163. + u32 addr_hi;
  164. + u32 count;
  165. + u8 mode;
  166. + u8 size;
  167. + u8 order_id;
  168. + u16 virtid;
  169. + u8 asel;
  170. +};
  171. /**
  172. * struct ti_sci_rm_ringacc_ops - Ring Accelerator Management operations
  173. * @config: configure the SoC Navigator Subsystem Ring Accelerator ring
  174. + * Deprecated
  175. + * @set_cfg: configure the SoC Navigator Subsystem Ring Accelerator ring
  176. */
  177. struct ti_sci_rm_ringacc_ops {
  178. int (*config)(const struct ti_sci_handle *handle,
  179. @@ -293,6 +320,8 @@ struct ti_sci_rm_ringacc_ops {
  180. u32 addr_lo, u32 addr_hi, u32 count, u8 mode,
  181. u8 size, u8 order_id
  182. );
  183. + int (*set_cfg)(const struct ti_sci_handle *handle,
  184. + const struct ti_sci_msg_rm_ring_cfg *params);
  185. };
  186. /**