Commit ebe9b300 authored by Linus Walleij's avatar Linus Walleij Committed by Vinod Koul

dmaengine: pl08x: Make slave engine optional

If the vendor data does not specify any signals, we do not
have to support slave DMA. Make the registration of the slave
DMA engine optional, so we can use this for the FTDMAC020
in the Gemini that only has memcpy support.
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
parent 9e972571
...@@ -253,8 +253,9 @@ struct pl08x_dma_chan { ...@@ -253,8 +253,9 @@ struct pl08x_dma_chan {
/** /**
* struct pl08x_driver_data - the local state holder for the PL08x * struct pl08x_driver_data - the local state holder for the PL08x
* @slave: slave engine for this instance * @slave: optional slave engine for this instance
* @memcpy: memcpy engine for this instance * @memcpy: memcpy engine for this instance
* @has_slave: the PL08x has a slave engine (routed signals)
* @base: virtual memory base (remapped) for the PL08x * @base: virtual memory base (remapped) for the PL08x
* @adev: the corresponding AMBA (PrimeCell) bus entry * @adev: the corresponding AMBA (PrimeCell) bus entry
* @vd: vendor data for this PL08x variant * @vd: vendor data for this PL08x variant
...@@ -269,6 +270,7 @@ struct pl08x_dma_chan { ...@@ -269,6 +270,7 @@ struct pl08x_dma_chan {
struct pl08x_driver_data { struct pl08x_driver_data {
struct dma_device slave; struct dma_device slave;
struct dma_device memcpy; struct dma_device memcpy;
bool has_slave;
void __iomem *base; void __iomem *base;
struct amba_device *adev; struct amba_device *adev;
const struct vendor_data *vd; const struct vendor_data *vd;
...@@ -705,7 +707,7 @@ static void pl08x_phy_free(struct pl08x_dma_chan *plchan) ...@@ -705,7 +707,7 @@ static void pl08x_phy_free(struct pl08x_dma_chan *plchan)
break; break;
} }
if (!next) { if (!next && pl08x->has_slave) {
list_for_each_entry(p, &pl08x->slave.channels, vc.chan.device_node) list_for_each_entry(p, &pl08x->slave.channels, vc.chan.device_node)
if (p->state == PL08X_CHAN_WAITING) { if (p->state == PL08X_CHAN_WAITING) {
next = p; next = p;
...@@ -2085,13 +2087,16 @@ static int pl08x_debugfs_show(struct seq_file *s, void *data) ...@@ -2085,13 +2087,16 @@ static int pl08x_debugfs_show(struct seq_file *s, void *data)
pl08x_state_str(chan->state)); pl08x_state_str(chan->state));
} }
if (pl08x->has_slave) {
seq_printf(s, "\nPL08x virtual slave channels:\n"); seq_printf(s, "\nPL08x virtual slave channels:\n");
seq_printf(s, "CHANNEL:\tSTATE:\n"); seq_printf(s, "CHANNEL:\tSTATE:\n");
seq_printf(s, "--------\t------\n"); seq_printf(s, "--------\t------\n");
list_for_each_entry(chan, &pl08x->slave.channels, vc.chan.device_node) { list_for_each_entry(chan, &pl08x->slave.channels,
vc.chan.device_node) {
seq_printf(s, "%s\t\t%s\n", chan->name, seq_printf(s, "%s\t\t%s\n", chan->name,
pl08x_state_str(chan->state)); pl08x_state_str(chan->state));
} }
}
return 0; return 0;
} }
...@@ -2128,6 +2133,10 @@ static struct dma_chan *pl08x_find_chan_id(struct pl08x_driver_data *pl08x, ...@@ -2128,6 +2133,10 @@ static struct dma_chan *pl08x_find_chan_id(struct pl08x_driver_data *pl08x,
{ {
struct pl08x_dma_chan *chan; struct pl08x_dma_chan *chan;
/* Trying to get a slave channel from something with no slave support */
if (!pl08x->has_slave)
return NULL;
list_for_each_entry(chan, &pl08x->slave.channels, vc.chan.device_node) { list_for_each_entry(chan, &pl08x->slave.channels, vc.chan.device_node) {
if (chan->signal == id) if (chan->signal == id)
return &chan->vc.chan; return &chan->vc.chan;
...@@ -2265,6 +2274,7 @@ static int pl08x_of_probe(struct amba_device *adev, ...@@ -2265,6 +2274,7 @@ static int pl08x_of_probe(struct amba_device *adev,
* for a device and have it's AHB interfaces set up at * for a device and have it's AHB interfaces set up at
* translation time. * translation time.
*/ */
if (pl08x->vd->signals) {
chanp = devm_kcalloc(&adev->dev, chanp = devm_kcalloc(&adev->dev,
pl08x->vd->signals, pl08x->vd->signals,
sizeof(struct pl08x_channel_data), sizeof(struct pl08x_channel_data),
...@@ -2274,11 +2284,14 @@ static int pl08x_of_probe(struct amba_device *adev, ...@@ -2274,11 +2284,14 @@ static int pl08x_of_probe(struct amba_device *adev,
pd->slave_channels = chanp; pd->slave_channels = chanp;
for (i = 0; i < pl08x->vd->signals; i++) { for (i = 0; i < pl08x->vd->signals; i++) {
/* chanp->periph_buses will be assigned at translation */ /*
* chanp->periph_buses will be assigned at translation
*/
chanp->bus_id = kasprintf(GFP_KERNEL, "slave%d", i); chanp->bus_id = kasprintf(GFP_KERNEL, "slave%d", i);
chanp++; chanp++;
} }
pd->num_slave_channels = pl08x->vd->signals; pd->num_slave_channels = pl08x->vd->signals;
}
pl08x->pd = pd; pl08x->pd = pd;
...@@ -2340,12 +2353,19 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id) ...@@ -2340,12 +2353,19 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id)
pl08x->memcpy.directions = BIT(DMA_MEM_TO_MEM); pl08x->memcpy.directions = BIT(DMA_MEM_TO_MEM);
pl08x->memcpy.residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT; pl08x->memcpy.residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT;
/* Initialize slave engine */ /*
* Initialize slave engine, if the block has no signals, that means
* we have no slave support.
*/
if (vd->signals) {
pl08x->has_slave = true;
dma_cap_set(DMA_SLAVE, pl08x->slave.cap_mask); dma_cap_set(DMA_SLAVE, pl08x->slave.cap_mask);
dma_cap_set(DMA_CYCLIC, pl08x->slave.cap_mask); dma_cap_set(DMA_CYCLIC, pl08x->slave.cap_mask);
pl08x->slave.dev = &adev->dev; pl08x->slave.dev = &adev->dev;
pl08x->slave.device_free_chan_resources = pl08x_free_chan_resources; pl08x->slave.device_free_chan_resources =
pl08x->slave.device_prep_dma_interrupt = pl08x_prep_dma_interrupt; pl08x_free_chan_resources;
pl08x->slave.device_prep_dma_interrupt =
pl08x_prep_dma_interrupt;
pl08x->slave.device_tx_status = pl08x_dma_tx_status; pl08x->slave.device_tx_status = pl08x_dma_tx_status;
pl08x->slave.device_issue_pending = pl08x_issue_pending; pl08x->slave.device_issue_pending = pl08x_issue_pending;
pl08x->slave.device_prep_slave_sg = pl08x_prep_slave_sg; pl08x->slave.device_prep_slave_sg = pl08x_prep_slave_sg;
...@@ -2356,8 +2376,11 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id) ...@@ -2356,8 +2376,11 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id)
pl08x->slave.device_terminate_all = pl08x_terminate_all; pl08x->slave.device_terminate_all = pl08x_terminate_all;
pl08x->slave.src_addr_widths = PL80X_DMA_BUSWIDTHS; pl08x->slave.src_addr_widths = PL80X_DMA_BUSWIDTHS;
pl08x->slave.dst_addr_widths = PL80X_DMA_BUSWIDTHS; pl08x->slave.dst_addr_widths = PL80X_DMA_BUSWIDTHS;
pl08x->slave.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV); pl08x->slave.directions =
pl08x->slave.residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT; BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
pl08x->slave.residue_granularity =
DMA_RESIDUE_GRANULARITY_SEGMENT;
}
/* Get the platform data */ /* Get the platform data */
pl08x->pd = dev_get_platdata(&adev->dev); pl08x->pd = dev_get_platdata(&adev->dev);
...@@ -2465,6 +2488,7 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id) ...@@ -2465,6 +2488,7 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id)
} }
/* Register slave channels */ /* Register slave channels */
if (pl08x->has_slave) {
ret = pl08x_dma_init_virtual_channels(pl08x, &pl08x->slave, ret = pl08x_dma_init_virtual_channels(pl08x, &pl08x->slave,
pl08x->pd->num_slave_channels, true); pl08x->pd->num_slave_channels, true);
if (ret < 0) { if (ret < 0) {
...@@ -2473,6 +2497,7 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id) ...@@ -2473,6 +2497,7 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id)
__func__, ret); __func__, ret);
goto out_no_slave; goto out_no_slave;
} }
}
ret = dma_async_device_register(&pl08x->memcpy); ret = dma_async_device_register(&pl08x->memcpy);
if (ret) { if (ret) {
...@@ -2482,6 +2507,7 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id) ...@@ -2482,6 +2507,7 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id)
goto out_no_memcpy_reg; goto out_no_memcpy_reg;
} }
if (pl08x->has_slave) {
ret = dma_async_device_register(&pl08x->slave); ret = dma_async_device_register(&pl08x->slave);
if (ret) { if (ret) {
dev_warn(&pl08x->adev->dev, dev_warn(&pl08x->adev->dev,
...@@ -2489,6 +2515,7 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id) ...@@ -2489,6 +2515,7 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id)
__func__, ret); __func__, ret);
goto out_no_slave_reg; goto out_no_slave_reg;
} }
}
amba_set_drvdata(adev, pl08x); amba_set_drvdata(adev, pl08x);
init_pl08x_debugfs(pl08x); init_pl08x_debugfs(pl08x);
...@@ -2501,6 +2528,7 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id) ...@@ -2501,6 +2528,7 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id)
out_no_slave_reg: out_no_slave_reg:
dma_async_device_unregister(&pl08x->memcpy); dma_async_device_unregister(&pl08x->memcpy);
out_no_memcpy_reg: out_no_memcpy_reg:
if (pl08x->has_slave)
pl08x_free_virtual_channels(&pl08x->slave); pl08x_free_virtual_channels(&pl08x->slave);
out_no_slave: out_no_slave:
pl08x_free_virtual_channels(&pl08x->memcpy); pl08x_free_virtual_channels(&pl08x->memcpy);
......
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