Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

firmware: ti_sci: rm: Add new ops for ring configuration

The sysfw ring configuration message has been extended to include virtid
and asel value for the ring.
Add the ASEL_VALID to TI_SCI_MSG_VALUE_RM_ALL_NO_ORDER as it is required
for DMA rings.

Instead of extending the current .config() ops - which would need same
patch change in the ringacc driver - add ti_sci_msg_rm_ring_cfg struct and
a new ops using it to configure the ring.

This will allow easy update path in case new members are added for the ring
configuration.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>

authored by

Peter Ujfalusi and committed by
Santosh Shilimkar
3c201753 4d8ddf67

+100 -1
+63
drivers/firmware/ti_sci.c
··· 2120 2120 } 2121 2121 2122 2122 /** 2123 + * ti_sci_cmd_rm_ring_cfg() - Configure a NAVSS ring 2124 + * @handle: Pointer to TI SCI handle. 2125 + * @params: Pointer to ti_sci_msg_rm_ring_cfg ring config structure 2126 + * 2127 + * Return: 0 if all went well, else returns appropriate error value. 2128 + * 2129 + * See @ti_sci_msg_rm_ring_cfg and @ti_sci_msg_rm_ring_cfg_req for 2130 + * more info. 2131 + */ 2132 + static int ti_sci_cmd_rm_ring_cfg(const struct ti_sci_handle *handle, 2133 + const struct ti_sci_msg_rm_ring_cfg *params) 2134 + { 2135 + struct ti_sci_msg_rm_ring_cfg_req *req; 2136 + struct ti_sci_msg_hdr *resp; 2137 + struct ti_sci_xfer *xfer; 2138 + struct ti_sci_info *info; 2139 + struct device *dev; 2140 + int ret = 0; 2141 + 2142 + if (IS_ERR_OR_NULL(handle)) 2143 + return -EINVAL; 2144 + 2145 + info = handle_to_ti_sci_info(handle); 2146 + dev = info->dev; 2147 + 2148 + xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_RM_RING_CFG, 2149 + TI_SCI_FLAG_REQ_ACK_ON_PROCESSED, 2150 + sizeof(*req), sizeof(*resp)); 2151 + if (IS_ERR(xfer)) { 2152 + ret = PTR_ERR(xfer); 2153 + dev_err(dev, "RM_RA:Message config failed(%d)\n", ret); 2154 + return ret; 2155 + } 2156 + req = (struct ti_sci_msg_rm_ring_cfg_req *)xfer->xfer_buf; 2157 + req->valid_params = params->valid_params; 2158 + req->nav_id = params->nav_id; 2159 + req->index = params->index; 2160 + req->addr_lo = params->addr_lo; 2161 + req->addr_hi = params->addr_hi; 2162 + req->count = params->count; 2163 + req->mode = params->mode; 2164 + req->size = params->size; 2165 + req->order_id = params->order_id; 2166 + req->virtid = params->virtid; 2167 + req->asel = params->asel; 2168 + 2169 + ret = ti_sci_do_xfer(info, xfer); 2170 + if (ret) { 2171 + dev_err(dev, "RM_RA:Mbox config send fail %d\n", ret); 2172 + goto fail; 2173 + } 2174 + 2175 + resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf; 2176 + ret = ti_sci_is_response_ack(resp) ? 0 : -EINVAL; 2177 + 2178 + fail: 2179 + ti_sci_put_one_xfer(&info->minfo, xfer); 2180 + dev_dbg(dev, "RM_RA:config ring %u ret:%d\n", params->index, ret); 2181 + return ret; 2182 + } 2183 + 2184 + /** 2123 2185 * ti_sci_cmd_rm_psil_pair() - Pair PSI-L source to destination thread 2124 2186 * @handle: Pointer to TI SCI handle. 2125 2187 * @nav_id: Device ID of Navigator Subsystem which should be used for ··· 2909 2847 iops->free_event_map = ti_sci_cmd_free_event_map; 2910 2848 2911 2849 rops->config = ti_sci_cmd_ring_config; 2850 + rops->set_cfg = ti_sci_cmd_rm_ring_cfg; 2912 2851 2913 2852 psilops->pair = ti_sci_cmd_rm_psil_pair; 2914 2853 psilops->unpair = ti_sci_cmd_rm_psil_unpair;
+7
drivers/firmware/ti_sci.h
··· 659 659 * 3 - Valid bit for @tisci_msg_rm_ring_cfg_req mode 660 660 * 4 - Valid bit for @tisci_msg_rm_ring_cfg_req size 661 661 * 5 - Valid bit for @tisci_msg_rm_ring_cfg_req order_id 662 + * 6 - Valid bit for @tisci_msg_rm_ring_cfg_req virtid 663 + * 7 - Valid bit for @tisci_msg_rm_ring_cfg_req ASEL 662 664 * @nav_id: Device ID of Navigator Subsystem from which the ring is allocated 663 665 * @index: ring index to be configured. 664 666 * @addr_lo: 32 LSBs of ring base address to be programmed into the ring's ··· 674 672 * the formula (log2(size_bytes) - 2), where size_bytes cannot be 675 673 * greater than 256. 676 674 * @order_id: Specifies the ring's bus order ID. 675 + * @virtid: Ring virt ID value 676 + * @asel: Ring ASEL (address select) value to be set into the ASEL field of the 677 + * ring's RING_BA_HI register. 677 678 */ 678 679 struct ti_sci_msg_rm_ring_cfg_req { 679 680 struct ti_sci_msg_hdr hdr; ··· 689 684 u8 mode; 690 685 u8 size; 691 686 u8 order_id; 687 + u16 virtid; 688 + u8 asel; 692 689 } __packed; 693 690 694 691 /**
+30 -1
include/linux/soc/ti/ti_sci_protocol.h
··· 275 275 #define TI_SCI_MSG_VALUE_RM_RING_SIZE_VALID BIT(4) 276 276 /* RA config.order_id parameter is valid for RM ring configure TISCI message */ 277 277 #define TI_SCI_MSG_VALUE_RM_RING_ORDER_ID_VALID BIT(5) 278 + /* RA config.virtid parameter is valid for RM ring configure TISCI message */ 279 + #define TI_SCI_MSG_VALUE_RM_RING_VIRTID_VALID BIT(6) 280 + /* RA config.asel parameter is valid for RM ring configure TISCI message */ 281 + #define TI_SCI_MSG_VALUE_RM_RING_ASEL_VALID BIT(7) 278 282 279 283 #define TI_SCI_MSG_VALUE_RM_ALL_NO_ORDER \ 280 284 (TI_SCI_MSG_VALUE_RM_RING_ADDR_LO_VALID | \ 281 285 TI_SCI_MSG_VALUE_RM_RING_ADDR_HI_VALID | \ 282 286 TI_SCI_MSG_VALUE_RM_RING_COUNT_VALID | \ 283 287 TI_SCI_MSG_VALUE_RM_RING_MODE_VALID | \ 284 - TI_SCI_MSG_VALUE_RM_RING_SIZE_VALID) 288 + TI_SCI_MSG_VALUE_RM_RING_SIZE_VALID | \ 289 + TI_SCI_MSG_VALUE_RM_RING_ASEL_VALID) 290 + 291 + /** 292 + * struct ti_sci_msg_rm_ring_cfg - Ring configuration 293 + * 294 + * Parameters for Navigator Subsystem ring configuration 295 + * See @ti_sci_msg_rm_ring_cfg_req 296 + */ 297 + struct ti_sci_msg_rm_ring_cfg { 298 + u32 valid_params; 299 + u16 nav_id; 300 + u16 index; 301 + u32 addr_lo; 302 + u32 addr_hi; 303 + u32 count; 304 + u8 mode; 305 + u8 size; 306 + u8 order_id; 307 + u16 virtid; 308 + u8 asel; 309 + }; 285 310 286 311 /** 287 312 * struct ti_sci_rm_ringacc_ops - Ring Accelerator Management operations 288 313 * @config: configure the SoC Navigator Subsystem Ring Accelerator ring 314 + * Deprecated 315 + * @set_cfg: configure the SoC Navigator Subsystem Ring Accelerator ring 289 316 */ 290 317 struct ti_sci_rm_ringacc_ops { 291 318 int (*config)(const struct ti_sci_handle *handle, ··· 320 293 u32 addr_lo, u32 addr_hi, u32 count, u8 mode, 321 294 u8 size, u8 order_id 322 295 ); 296 + int (*set_cfg)(const struct ti_sci_handle *handle, 297 + const struct ti_sci_msg_rm_ring_cfg *params); 323 298 }; 324 299 325 300 /**