Commit 81a1f90f authored by Siddharth Vadapalli's avatar Siddharth Vadapalli Committed by Vinod Koul

dmaengine: ti: k3-udma-glue: Add function to parse channel by ID

The existing helper function of_k3_udma_glue_parse() fetches the DMA
Channel thread ID from the device-tree node. This makes it necessary to
have a device-tree node with the Channel thread IDs populated. However,
in the case where the thread ID is known by alternate methods (an
example being that of Firmware running on remote core sharing details of
the thread IDs), there is no equivalent function to implement the
functionality of the existing of_k3_udma_glue_parse() function. In such
cases, the driver utilizing the DMA APIs might not even have a
device-tree node to begin with, since it could be probed with other
methods (RPMsg-Bus for example).

Add the of_k3_udma_glue_parse_chn_by_id() helper function which accepts
the thread ID as an argument, thereby making it unnecessary to have a
device-tree node for obtaining the thread ID.

Since of_k3_udma_glue_parse() and of_k3_udma_glue_parse_chn_by_id()
share a lot of code in common, create a new function to handle the
common code which is named as of_k3_udma_glue_parse_chn_common().
Signed-off-by: default avatarSiddharth Vadapalli <s-vadapalli@ti.com>
Acked-by: default avatarPeter Ujfalusi <peter.ujfalusi@gmail.com>
Link: https://lore.kernel.org/r/20240124124319.820002-2-s-vadapalli@ti.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 7510bf84
...@@ -111,6 +111,35 @@ static int of_k3_udma_glue_parse(struct device_node *udmax_np, ...@@ -111,6 +111,35 @@ static int of_k3_udma_glue_parse(struct device_node *udmax_np,
return 0; return 0;
} }
static int of_k3_udma_glue_parse_chn_common(struct k3_udma_glue_common *common, u32 thread_id,
bool tx_chn)
{
if (tx_chn && !(thread_id & K3_PSIL_DST_THREAD_ID_OFFSET))
return -EINVAL;
if (!tx_chn && (thread_id & K3_PSIL_DST_THREAD_ID_OFFSET))
return -EINVAL;
/* get psil endpoint config */
common->ep_config = psil_get_ep_config(thread_id);
if (IS_ERR(common->ep_config)) {
dev_err(common->dev,
"No configuration for psi-l thread 0x%04x\n",
thread_id);
return PTR_ERR(common->ep_config);
}
common->epib = common->ep_config->needs_epib;
common->psdata_size = common->ep_config->psd_size;
if (tx_chn)
common->dst_thread = thread_id;
else
common->src_thread = thread_id;
return 0;
}
static int of_k3_udma_glue_parse_chn(struct device_node *chn_np, static int of_k3_udma_glue_parse_chn(struct device_node *chn_np,
const char *name, struct k3_udma_glue_common *common, const char *name, struct k3_udma_glue_common *common,
bool tx_chn) bool tx_chn)
...@@ -153,38 +182,32 @@ static int of_k3_udma_glue_parse_chn(struct device_node *chn_np, ...@@ -153,38 +182,32 @@ static int of_k3_udma_glue_parse_chn(struct device_node *chn_np,
common->atype_asel = dma_spec.args[1]; common->atype_asel = dma_spec.args[1];
} }
if (tx_chn && !(thread_id & K3_PSIL_DST_THREAD_ID_OFFSET)) { ret = of_k3_udma_glue_parse_chn_common(common, thread_id, tx_chn);
ret = -EINVAL;
goto out_put_spec;
}
if (!tx_chn && (thread_id & K3_PSIL_DST_THREAD_ID_OFFSET)) { out_put_spec:
ret = -EINVAL; of_node_put(dma_spec.np);
goto out_put_spec; return ret;
} }
/* get psil endpoint config */ static int
common->ep_config = psil_get_ep_config(thread_id); of_k3_udma_glue_parse_chn_by_id(struct device_node *udmax_np, struct k3_udma_glue_common *common,
if (IS_ERR(common->ep_config)) { bool tx_chn, u32 thread_id)
dev_err(common->dev, {
"No configuration for psi-l thread 0x%04x\n", int ret = 0;
thread_id);
ret = PTR_ERR(common->ep_config);
goto out_put_spec;
}
common->epib = common->ep_config->needs_epib; if (unlikely(!udmax_np))
common->psdata_size = common->ep_config->psd_size; return -EINVAL;
if (tx_chn) ret = of_k3_udma_glue_parse(udmax_np, common);
common->dst_thread = thread_id; if (ret)
else goto out_put_spec;
common->src_thread = thread_id;
ret = of_k3_udma_glue_parse_chn_common(common, thread_id, tx_chn);
out_put_spec: out_put_spec:
of_node_put(dma_spec.np); of_node_put(udmax_np);
return ret; return ret;
}; }
static void k3_udma_glue_dump_tx_chn(struct k3_udma_glue_tx_channel *tx_chn) static void k3_udma_glue_dump_tx_chn(struct k3_udma_glue_tx_channel *tx_chn)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment