dmaengine: pl08x: Support the Hi3798MV100 PL080 variant
v2 cover dmaengine: pl08x: Support the Hi3798MV100 PL080 variant
Hi3798MV100 (HiSilicon HiSTB) carries a PL080-class DMAC. The block reports 0x0a141080 -- the ID reserved for Samsung's PL080S -- while its register map is plain PL080 and the instance has 4 channels instead of the 8 the plain PL080 entry claims.
Set the DT node to arm,primecell-periphid = <0x00041080> and dma-channels = <4>, and apply the two patches to add that support.
Tested on Hi3798MV100 hardware.
v2:
- fix for shared reset
- use local copy of vendor_data
v1: https://lore.kernel.org/r/[email protected]/
David Yang (2):
dmaengine: pl08x: Release the reset before reading registers
dmaengine: pl08x: Use the channel count from the device tree
drivers/dma/amba-pl08x.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-)
Signature · 1 line
2.53.0
PATCH v2 1/2 dmaengine: pl08x: Release the reset before reading registers
amba_read_periphid() happens to release the reset. A node that carries arm,primecell-periphid never reaches it. Take the reset shared and release it ourselves.
--- drivers/dma/amba-pl08x.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/dma/amba-pl08x.c +9 -0
@@ -75,6 +75,7 @@#include <linux/of.h> #include <linux/of_dma.h> #include <linux/pm_runtime.h> +#include <linux/reset.h> #include <linux/seq_file.h> #include <linux/slab.h> #include <linux/amba/pl080.h>
@@ -2695,6 +2696,7 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id)struct pl08x_driver_data *pl08x;struct vendor_data *vd = id->data;struct device_node *np = adev->dev.of_node; +struct reset_control *rst;u32 tsfr_size;int ret =0 ;int i;
@@ -2725,6 +2727,13 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id) goto out_no_ioremap; } +/* Release the reset before reading registers */ + rst =devm_reset_control_get_optional_shared_deasserted (&adev->dev,NULL ); +if (IS_ERR (rst)) { + ret =PTR_ERR (rst); + goto out_no_platdata; + } +if (vd->ftdmac020) {u32 val;
Signature · 1 line
2.53.0
Re: [PATCH v2 1/2] dmaengine: pl08x: Release the reset before reading registers
Quoted 5 lines · David Yang
amba_read_periphid()happens to release the reset. A node that carries arm,primecell-periphid never reaches it. Take the reset shared and release it ourselves.Signed-off-by David Yang <[email protected]>
regards
Philipp
Re: [PATCH v2 1/2] dmaengine: pl08x: Release the reset before reading registers
In reply to David YangQuoted 8 lines · David Yang
[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
amba_read_periphid()happens to release the reset. A node that carries arm,primecell-periphid never reaches it. Take the reset shared and release it ourselves.Signed-off-by David Yang <[email protected]>---
Quoted 40 lines
drivers/dma/amba-pl08x.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/dma/amba-pl08x.c +9
-1@@ -75,6 +75,7 @@#include <linux/of.h> #include <linux/of_dma.h> #include <linux/pm_runtime.h> +#include <linux/reset.h> #include <linux/seq_file.h> #include <linux/slab.h> #include <linux/amba/pl080.h> @@ -2695,6 +2696,7 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id)struct pl08x_driver_data *pl08x;struct vendor_data *vd = id->data;struct device_node *np = adev->dev.of_node; +struct reset_control *rst;u32 tsfr_size;int ret =0 ;int i;@@ -2725,6 +2727,13 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id) goto out_no_ioremap; } +/* Release the reset before reading registers */ + rst =devm_reset_control_get_optional_shared_deasserted (&adev->dev,NULL ); +if (IS_ERR (rst)) { + ret =PTR_ERR (rst); + goto out_no_platdata; + } +if (vd->ftdmac020) {u32 val; --2.53.0
PATCH v2 2/2 dmaengine: pl08x: Use the channel count from the device tree
In reply to David YangThe Hi3798MV100 DMAC is a plain PL080 except for the channel count: 4 instead of 8. The part ID does not say, and the driver takes the count from the matched vendor_data entry. The entry is shared between instances; the adjustment lands in a private copy. dma-common.yaml already defines dma-channels for a controller node. Honor it.
--- drivers/dma/amba-pl08x.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)
drivers/dma/amba-pl08x.c +23 -2
@@ -282,7 +282,7 @@ struct pl08x_driver_data {bool has_slave;void __iomem *base;struct amba_device *adev; -const struct vendor_data *vd; +struct vendor_data *vd;struct pl08x_platform_data *pd;struct pl08x_phy_chan *phy_chans;struct dma_pool *pool;
@@ -2698,6 +2698,7 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id)struct device_node *np = adev->dev.of_node;struct reset_control *rst;u32 tsfr_size; +u32 channels;int ret =0 ;int i;
@@ -2719,7 +2720,6 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id)/* Assign useful pointers to the driver state */ pl08x->adev = adev; - pl08x->vd = vd; pl08x->base =ioremap (adev->res.start,resource_size (&adev->res));if (!pl08x->base) {
@@ -2727,6 +2727,17 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id) goto out_no_ioremap; } +/* +* vd points into the shared id table; give the instance its own +* copy before anything below starts adjusting it. +*/ + pl08x->vd =devm_kmemdup (&adev->dev, vd,sizeof (*vd),GFP_KERNEL ); +if (!pl08x->vd) { + ret = -ENOMEM ; + goto out_no_platdata; + } + vd = pl08x->vd; +/* Release the reset before reading registers */ rst =devm_reset_control_get_optional_shared_deasserted (&adev->dev,NULL );if (IS_ERR (rst)) {
@@ -2756,6 +2767,16 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id) vd->dualmaster = !!(val &BIT (9 )); } +/* Read the channel number from the node if specified */ +if (!of_property_read_u32 (np,"dma-channels" , &channels) && channels) { +if (channels > vd->channels) +dev_warn (&adev->dev, +"using %u channels, instead of %u from the node\n" , + vd->channels, channels); +else + vd->channels = channels; + } +/* Initialize memcpy engine */ dma_cap_set (DMA_MEMCPY , pl08x->memcpy.cap_mask); pl08x->memcpy.dev = &adev->dev;
Signature · 1 line
2.53.0
Re: [PATCH v2 2/2] dmaengine: pl08x: Use the channel count from the device tree
Quoted 10 lines · David Yang
[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
The Hi3798MV100 DMAC is a plain PL080 except for the channel count: 4 instead of 8. The part ID does not say, and the driver takes the count from the matched
vendor_dataentry. The entry is shared between instances; the adjustment lands in a private copy.dma-common.yamlalready defines dma-channels for a controller node. Honor it.Signed-off-by David Yang <[email protected]>---
Quoted 70 lines
drivers/dma/amba-pl08x.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)drivers/dma/amba-pl08x.c +23
-3@@ -282,7 +282,7 @@ struct pl08x_driver_data {bool has_slave;void __iomem *base;struct amba_device *adev; -const struct vendor_data *vd; +struct vendor_data *vd;struct pl08x_platform_data *pd;struct pl08x_phy_chan *phy_chans;struct dma_pool *pool;@@ -2698,6 +2698,7 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id)struct device_node *np = adev->dev.of_node;struct reset_control *rst;u32 tsfr_size; +u32 channels;int ret =0 ;int i;@@ -2719,7 +2720,6 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id)/* Assign useful pointers to the driver state */ pl08x->adev = adev; - pl08x->vd = vd; pl08x->base =ioremap (adev->res.start,resource_size (&adev->res));if (!pl08x->base) {@@ -2727,6 +2727,17 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id) goto out_no_ioremap; } +/* +* vd points into the shared id table; give the instance its own +* copy before anything below starts adjusting it. +*/ + pl08x->vd =devm_kmemdup (&adev->dev, vd,sizeof (*vd),GFP_KERNEL ); +if (!pl08x->vd) { + ret = -ENOMEM ; + goto out_no_platdata; + } + vd = pl08x->vd; +/* Release the reset before reading registers */ rst =devm_reset_control_get_optional_shared_deasserted (&adev->dev,NULL );if (IS_ERR (rst)) {@@ -2756,6 +2767,16 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id) vd->dualmaster = !!(val &BIT (9 )); } +/* Read the channel number from the node if specified */ +if (!of_property_read_u32 (np,"dma-channels" , &channels) && channels) { +if (channels > vd->channels) +dev_warn (&adev->dev, +"using %u channels, instead of %u from the node\n" , + vd->channels, channels); +else + vd->channels = channels; + } +/* Initialize memcpy engine */ dma_cap_set (DMA_MEMCPY , pl08x->memcpy.cap_mask); pl08x->memcpy.dev = &adev->dev; --2.53.0