2017-08-01 15:49:44

by Suman Anna

[permalink] [raw]
Subject: [PATCH v2 0/4] Add DT support for davinci remoteproc driver

Hi,

The following is v2 of the series [1] that adds the device tree support to
the Davinci remoteproc driver. Patches are baselined on 4.13-rc1, the
main dependent patches from the series "Davinci remoteproc cleanup/fixes"
[2] and the resource name additions [3] were merged and available in
mainline 4.13-rc1.

DTS nodes for the OMAP-L138 LCDK board will be added for a subsequent merge
window once these patches are picked up.

Change summary for v2:
- Patches 1 and 2 are unchanged
- Binding in Patch 3 revised slightly to address Rob Herring's comments
- Patch 4 updated to deal with non-OF builds since Davinci platforms still
support non-DT boots.

regards
Suman

[1] http://marc.info/?l=linux-arm-kernel&m=149514538506046&w=2
[2] http://marc.info/?l=linux-arm-kernel&m=149514538506046&w=2
[3] http://marc.info/?l=linux-kernel&m=149497287512869&w=2

Suman Anna (4):
remoteproc/davinci: Switch to platform_get_resource_byname()
remoteproc/davinci: Add support to parse internal memories
dt-bindings: remoteproc: Add bindings for Davinci DSP processors
remoteproc/davinci: Add device tree support for OMAP-L138 DSP

.../bindings/remoteproc/ti,davinci-rproc.txt | 86 +++++++++++++++++++
drivers/remoteproc/da8xx_remoteproc.c | 98 ++++++++++++++++++++--
2 files changed, 179 insertions(+), 5 deletions(-)
create mode 100644 Documentation/devicetree/bindings/remoteproc/ti,davinci-rproc.txt

--
2.13.1


2017-08-01 15:49:21

by Suman Anna

[permalink] [raw]
Subject: [PATCH v2 3/4] dt-bindings: remoteproc: Add bindings for Davinci DSP processors

Add the device tree bindings document for the DSP processor
subsystem devices on TI Davinci DA8xx/OMAP-L13x SoCs.

Signed-off-by: Suman Anna <[email protected]>
---
v2:
- Updated the patch header
- Revised the binding status statement slightly
- Updated the example to address Rob's comments
- No changes in properties description themselves
v1: https://patchwork.kernel.org/patch/9751269/

.../bindings/remoteproc/ti,davinci-rproc.txt | 86 ++++++++++++++++++++++
1 file changed, 86 insertions(+)
create mode 100644 Documentation/devicetree/bindings/remoteproc/ti,davinci-rproc.txt

diff --git a/Documentation/devicetree/bindings/remoteproc/ti,davinci-rproc.txt b/Documentation/devicetree/bindings/remoteproc/ti,davinci-rproc.txt
new file mode 100644
index 000000000000..e44a97e21164
--- /dev/null
+++ b/Documentation/devicetree/bindings/remoteproc/ti,davinci-rproc.txt
@@ -0,0 +1,86 @@
+TI Davinci DSP devices
+=======================
+
+Binding status: Unstable - Subject to changes for DT representation of clocks
+ and resets
+
+The TI Davinci family of SoCs usually contains a TI DSP Core sub-system that
+is used to offload some of the processor-intensive tasks or algorithms, for
+achieving various system level goals.
+
+The processor cores in the sub-system usually contain additional sub-modules
+like L1 and/or L2 caches/SRAMs, an Interrupt Controller, an external memory
+controller, a dedicated local power/sleep controller etc. The DSP processor
+core used in Davinci SoCs is usually a C674x DSP CPU.
+
+DSP Device Node:
+================
+Each DSP Core sub-system is represented as a single DT node.
+
+Required properties:
+--------------------
+The following are the mandatory properties:
+
+- compatible: Should be one of the following,
+ "ti,da850-dsp" for DSPs on OMAP-L138 SoCs
+
+- reg: Should contain an entry for each value in 'reg-names'.
+ Each entry should have the memory region's start address
+ and the size of the region, the representation matching
+ the parent node's '#address-cells' and '#size-cells' values.
+
+- reg-names: Should contain strings with the following names, each
+ representing a specific internal memory region or a
+ specific register space,
+ "l2sram", "l1pram", "l1dram", "host1cfg", "chipsig_base"
+
+- interrupts: Should contain the interrupt number used to receive the
+ interrupts from the DSP. The value should follow the
+ interrupt-specifier format as dictated by the
+ 'interrupt-parent' node.
+
+- memory-region: phandle to the reserved memory node to be associated
+ with the remoteproc device. The reserved memory node
+ can be a CMA memory node, and should be defined as
+ per the bindings in
+ Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt
+
+Optional properties:
+--------------------
+- interrupt-parent: phandle to the interrupt controller node. This property
+ is needed if the device node hierarchy doesn't have an
+ interrupt controller.
+
+
+Example:
+--------
+
+ /* DSP Reserved Memory node */
+ reserved-memory {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ ranges;
+
+ dsp_memory_region: dsp-memory@c3000000 {
+ compatible = "shared-dma-pool";
+ reg = <0xc3000000 0x1000000>;
+ reusable;
+ };
+ };
+
+ /* DSP node */
+ {
+ dsp: dsp@11800000 {
+ compatible = "ti,da850-dsp";
+ reg = <0x11800000 0x40000>,
+ <0x11e00000 0x8000>,
+ <0x11f00000 0x8000>,
+ <0x01c14044 0x4>,
+ <0x01c14174 0x8>;
+ reg-names = "l2sram", "l1pram", "l1dram", "host1cfg",
+ "chipsig";
+ interrupt-parent = <&intc>;
+ interrupts = <28>;
+ memory-region = <&dsp_memory_region>;
+ };
+ };
--
2.13.1

2017-08-01 15:49:20

by Suman Anna

[permalink] [raw]
Subject: [PATCH v2 1/4] remoteproc/davinci: Switch to platform_get_resource_byname()

The davinci remoteproc driver currently uses the platform_get_resource()
API for retrieving the IOMEM resources. Switch this function to use the
platform_get_resource_byname() API instead in preparation for adding the
DT support so that the binding can be agnostic of the IOMEM resource
order.

Signed-off-by: Suman Anna <[email protected]>
---
v2: No changes

drivers/remoteproc/da8xx_remoteproc.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/remoteproc/da8xx_remoteproc.c b/drivers/remoteproc/da8xx_remoteproc.c
index 99539cec1329..280b66d4f622 100644
--- a/drivers/remoteproc/da8xx_remoteproc.c
+++ b/drivers/remoteproc/da8xx_remoteproc.c
@@ -184,12 +184,14 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
return -EINVAL;
}

- bootreg_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ bootreg_res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+ "host1cfg");
bootreg = devm_ioremap_resource(dev, bootreg_res);
if (IS_ERR(bootreg))
return PTR_ERR(bootreg);

- chipsig_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+ chipsig_res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+ "chipsig");
chipsig = devm_ioremap_resource(dev, chipsig_res);
if (IS_ERR(chipsig))
return PTR_ERR(chipsig);
--
2.13.1

2017-08-01 15:52:00

by Suman Anna

[permalink] [raw]
Subject: [PATCH v2 2/4] remoteproc/davinci: Add support to parse internal memories

The DSP subsystem on OMAP-L13x SoCs has various internal RAM
memories that can accessed from the ARM side. These memories
can be configured to be used as either RAM or Cache.

The Davinci remoteproc driver has been enhanced to parse and
store the kernel mappings for these internal RAM memories.
These mappings can then be used to support direct loading of
text/data into these memories from the remoteproc driver.

Signed-off-by: Suman Anna <[email protected]>
---
v2: No code changes

drivers/remoteproc/da8xx_remoteproc.c | 62 +++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)

diff --git a/drivers/remoteproc/da8xx_remoteproc.c b/drivers/remoteproc/da8xx_remoteproc.c
index 280b66d4f622..c1cff78de67b 100644
--- a/drivers/remoteproc/da8xx_remoteproc.c
+++ b/drivers/remoteproc/da8xx_remoteproc.c
@@ -38,9 +38,27 @@ MODULE_PARM_DESC(da8xx_fw_name,
#define SYSCFG_CHIPSIG3 BIT(3)
#define SYSCFG_CHIPSIG4 BIT(4)

+#define DA8XX_RPROC_LOCAL_ADDRESS_MASK (SZ_16M - 1)
+
+/**
+ * struct da8xx_rproc_mem - internal memory structure
+ * @cpu_addr: MPU virtual address of the memory region
+ * @bus_addr: Bus address used to access the memory region
+ * @dev_addr: Device address of the memory region from DSP view
+ * @size: Size of the memory region
+ */
+struct da8xx_rproc_mem {
+ void __iomem *cpu_addr;
+ phys_addr_t bus_addr;
+ u32 dev_addr;
+ size_t size;
+};
+
/**
* struct da8xx_rproc - da8xx remote processor instance state
* @rproc: rproc handle
+ * @mem: internal memory regions data
+ * @num_mems: number of internal memory regions
* @dsp_clk: placeholder for platform's DSP clk
* @ack_fxn: chip-specific ack function for ack'ing irq
* @irq_data: ack_fxn function parameter
@@ -50,6 +68,8 @@ MODULE_PARM_DESC(da8xx_fw_name,
*/
struct da8xx_rproc {
struct rproc *rproc;
+ struct da8xx_rproc_mem *mem;
+ int num_mems;
struct clk *dsp_clk;
void (*ack_fxn)(struct irq_data *data);
struct irq_data *irq_data;
@@ -158,6 +178,44 @@ static const struct rproc_ops da8xx_rproc_ops = {
.kick = da8xx_rproc_kick,
};

+static int da8xx_rproc_get_internal_memories(struct platform_device *pdev,
+ struct da8xx_rproc *drproc)
+{
+ static const char * const mem_names[] = {"l2sram", "l1pram", "l1dram"};
+ int num_mems = ARRAY_SIZE(mem_names);
+ struct device *dev = &pdev->dev;
+ struct resource *res;
+ int i;
+
+ drproc->mem = devm_kcalloc(dev, num_mems, sizeof(*drproc->mem),
+ GFP_KERNEL);
+ if (!drproc->mem)
+ return -ENOMEM;
+
+ for (i = 0; i < num_mems; i++) {
+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+ mem_names[i]);
+ drproc->mem[i].cpu_addr = devm_ioremap_resource(dev, res);
+ if (IS_ERR(drproc->mem[i].cpu_addr)) {
+ dev_err(dev, "failed to parse and map %s memory\n",
+ mem_names[i]);
+ return PTR_ERR(drproc->mem[i].cpu_addr);
+ }
+ drproc->mem[i].bus_addr = res->start;
+ drproc->mem[i].dev_addr =
+ res->start & DA8XX_RPROC_LOCAL_ADDRESS_MASK;
+ drproc->mem[i].size = resource_size(res);
+
+ dev_dbg(dev, "memory %8s: bus addr %pa size 0x%x va %p da 0x%x\n",
+ mem_names[i], &drproc->mem[i].bus_addr,
+ drproc->mem[i].size, drproc->mem[i].cpu_addr,
+ drproc->mem[i].dev_addr);
+ }
+ drproc->num_mems = num_mems;
+
+ return 0;
+}
+
static int da8xx_rproc_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -213,6 +271,10 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
drproc->dsp_clk = dsp_clk;
rproc->has_iommu = false;

+ ret = da8xx_rproc_get_internal_memories(pdev, drproc);
+ if (ret)
+ goto free_rproc;
+
platform_set_drvdata(pdev, rproc);

/* everything the ISR needs is now setup, so hook it up */
--
2.13.1

2017-08-01 15:51:59

by Suman Anna

[permalink] [raw]
Subject: [PATCH v2 4/4] remoteproc/davinci: Add device tree support for OMAP-L138 DSP

The Davinci remoteproc driver currently supports the DSP remoteproc
device created in legacy-style on OMAP-L13x SoCs. The driver has been
enhanced to support the DSP remoteproc device created through Device
Tree now. The current DT support handles the C674x DSP processor
subsystem on OMAP-L138 SoCs.

Signed-off-by: Suman Anna <[email protected]>
---
v2:
- Add __maybe_unused and of_match_ptr to deal with non-OF builds
- Rebased patch after dropping the interrupt management patch from
the cleanup series, https://patchwork.kernel.org/patch/9735321/
v1: https://patchwork.kernel.org/patch/9751277/

drivers/remoteproc/da8xx_remoteproc.c | 30 +++++++++++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/drivers/remoteproc/da8xx_remoteproc.c b/drivers/remoteproc/da8xx_remoteproc.c
index c1cff78de67b..bf3b9034c319 100644
--- a/drivers/remoteproc/da8xx_remoteproc.c
+++ b/drivers/remoteproc/da8xx_remoteproc.c
@@ -16,6 +16,7 @@
#include <linux/irq.h>
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/of_reserved_mem.h>
#include <linux/platform_device.h>
#include <linux/remoteproc.h>

@@ -261,10 +262,21 @@ static int da8xx_rproc_probe(struct platform_device *pdev)
return PTR_ERR(dsp_clk);
}

+ if (dev->of_node) {
+ ret = of_reserved_mem_device_init(dev);
+ if (ret) {
+ dev_err(dev, "device does not have specific CMA pool: %d\n",
+ ret);
+ return ret;
+ }
+ }
+
rproc = rproc_alloc(dev, "dsp", &da8xx_rproc_ops, da8xx_fw_name,
sizeof(*drproc));
- if (!rproc)
- return -ENOMEM;
+ if (!rproc) {
+ ret = -ENOMEM;
+ goto free_mem;
+ }

drproc = rproc->priv;
drproc->rproc = rproc;
@@ -311,7 +323,9 @@ static int da8xx_rproc_probe(struct platform_device *pdev)

free_rproc:
rproc_free(rproc);
-
+free_mem:
+ if (dev->of_node)
+ of_reserved_mem_device_release(dev);
return ret;
}

@@ -319,6 +333,7 @@ static int da8xx_rproc_remove(struct platform_device *pdev)
{
struct rproc *rproc = platform_get_drvdata(pdev);
struct da8xx_rproc *drproc = (struct da8xx_rproc *)rproc->priv;
+ struct device *dev = &pdev->dev;

/*
* The devm subsystem might end up releasing things before
@@ -329,15 +344,24 @@ static int da8xx_rproc_remove(struct platform_device *pdev)

rproc_del(rproc);
rproc_free(rproc);
+ if (dev->of_node)
+ of_reserved_mem_device_release(dev);

return 0;
}

+static const struct of_device_id davinci_rproc_of_match[] __maybe_unused = {
+ { .compatible = "ti,da850-dsp", },
+ { /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, davinci_rproc_of_match);
+
static struct platform_driver da8xx_rproc_driver = {
.probe = da8xx_rproc_probe,
.remove = da8xx_rproc_remove,
.driver = {
.name = "davinci-rproc",
+ .of_match_table = of_match_ptr(davinci_rproc_of_match),
},
};

--
2.13.1

2017-08-01 16:56:13

by Suman Anna

[permalink] [raw]
Subject: Re: [PATCH v2 0/4] Add DT support for davinci remoteproc driver

On 08/01/2017 10:48 AM, Suman Anna wrote:
> Hi,
>
> The following is v2 of the series [1] that adds the device tree support to
> the Davinci remoteproc driver. Patches are baselined on 4.13-rc1, the
> main dependent patches from the series "Davinci remoteproc cleanup/fixes"
> [2] and the resource name additions [3] were merged and available in
> mainline 4.13-rc1.
>
> DTS nodes for the OMAP-L138 LCDK board will be added for a subsequent merge
> window once these patches are picked up.
>
> Change summary for v2:
> - Patches 1 and 2 are unchanged
> - Binding in Patch 3 revised slightly to address Rob Herring's comments
> - Patch 4 updated to deal with non-OF builds since Davinci platforms still
> support non-DT boots.
>
> regards
> Suman
>
> [1] http://marc.info/?l=linux-arm-kernel&m=149514538506046&w=2

Oops, pasted the wrong link, correct link is
http://marc.info/?l=linux-arm-kernel&m=149583015432586&w=2

> [2] http://marc.info/?l=linux-arm-kernel&m=149514538506046&w=2
> [3] http://marc.info/?l=linux-kernel&m=149497287512869&w=2
>
> Suman Anna (4):
> remoteproc/davinci: Switch to platform_get_resource_byname()
> remoteproc/davinci: Add support to parse internal memories
> dt-bindings: remoteproc: Add bindings for Davinci DSP processors
> remoteproc/davinci: Add device tree support for OMAP-L138 DSP
>
> .../bindings/remoteproc/ti,davinci-rproc.txt | 86 +++++++++++++++++++
> drivers/remoteproc/da8xx_remoteproc.c | 98 ++++++++++++++++++++--
> 2 files changed, 179 insertions(+), 5 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/remoteproc/ti,davinci-rproc.txt
>

2017-08-10 14:02:02

by Rob Herring (Arm)

[permalink] [raw]
Subject: Re: [PATCH v2 3/4] dt-bindings: remoteproc: Add bindings for Davinci DSP processors

On Tue, Aug 01, 2017 at 10:48:43AM -0500, Suman Anna wrote:
> Add the device tree bindings document for the DSP processor
> subsystem devices on TI Davinci DA8xx/OMAP-L13x SoCs.
>
> Signed-off-by: Suman Anna <[email protected]>
> ---
> v2:
> - Updated the patch header
> - Revised the binding status statement slightly
> - Updated the example to address Rob's comments
> - No changes in properties description themselves
> v1: https://patchwork.kernel.org/patch/9751269/
>
> .../bindings/remoteproc/ti,davinci-rproc.txt | 86 ++++++++++++++++++++++
> 1 file changed, 86 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/remoteproc/ti,davinci-rproc.txt

Acked-by: Rob Herring <[email protected]>

2017-08-10 15:06:03

by Suman Anna

[permalink] [raw]
Subject: Re: [PATCH v2 3/4] dt-bindings: remoteproc: Add bindings for Davinci DSP processors

On 08/10/2017 09:01 AM, Rob Herring wrote:
> On Tue, Aug 01, 2017 at 10:48:43AM -0500, Suman Anna wrote:
>> Add the device tree bindings document for the DSP processor
>> subsystem devices on TI Davinci DA8xx/OMAP-L13x SoCs.
>>
>> Signed-off-by: Suman Anna <[email protected]>
>> ---
>> v2:
>> - Updated the patch header
>> - Revised the binding status statement slightly
>> - Updated the example to address Rob's comments
>> - No changes in properties description themselves
>> v1: https://patchwork.kernel.org/patch/9751269/
>>
>> .../bindings/remoteproc/ti,davinci-rproc.txt | 86 ++++++++++++++++++++++
>> 1 file changed, 86 insertions(+)
>> create mode 100644 Documentation/devicetree/bindings/remoteproc/ti,davinci-rproc.txt
>
> Acked-by: Rob Herring <[email protected]>

Thanks Rob.

Bjorn,
Appreciate it if you can pick up the series for v4.14.

Thanks,
Suman