Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 50 additions & 8 deletions Documentation/devicetree/bindings/remoteproc/st,stm32-rproc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ maintainers:

properties:
compatible:
const: st,stm32mp1-m4
enum:
- st,stm32mp1-m4
- st,stm32mp1-m4-tee
description:
Use "st,stm32mp1-m4" for the Cortex-M4 coprocessor management by non-secure context
Use "st,stm32mp1-m4-tee" for the Cortex-M4 coprocessor management by secure context

reg:
description:
Expand All @@ -43,6 +48,10 @@ properties:
- description: The offset of the hold boot setting register
- description: The field mask of the hold boot

st,proc-id:
description: remote processor identifier
$ref: /schemas/types.yaml#/definitions/uint32

st,syscfg-tz:
deprecated: true
description:
Expand Down Expand Up @@ -146,21 +155,43 @@ properties:
required:
- compatible
- reg
- resets

allOf:
- if:
properties:
reset-names:
not:
contains:
const: hold_boot
compatible:
contains:
const: st,stm32mp1-m4
then:
if:
properties:
reset-names:
not:
contains:
const: hold_boot
then:
required:
- st,syscfg-holdboot
else:
properties:
st,syscfg-holdboot: false
required:
- reset-names
required:
- st,syscfg-holdboot
else:
- resets

- if:
properties:
compatible:
contains:
const: st,stm32mp1-m4-tee
then:
properties:
st,syscfg-holdboot: false
reset-names: false
resets: false
required:
- st,proc-id

additionalProperties: false

Expand Down Expand Up @@ -192,5 +223,16 @@ examples:
st,syscfg-rsc-tbl = <&tamp 0x144 0xFFFFFFFF>;
st,syscfg-m4-state = <&tamp 0x148 0xFFFFFFFF>;
};
- |
#include <dt-bindings/reset/stm32mp1-resets.h>
m4@10000000 {
compatible = "st,stm32mp1-m4-tee";
reg = <0x10000000 0x40000>,
<0x30000000 0x40000>,
<0x38000000 0x10000>;
st,proc-id = <0>;
st,syscfg-rsc-tbl = <&tamp 0x144 0xFFFFFFFF>;
st,syscfg-m4-state = <&tamp 0x148 0xFFFFFFFF>;
};

...
10 changes: 10 additions & 0 deletions drivers/remoteproc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ config REMOTEPROC_CDEV

It's safe to say N if you don't want to use this interface.

config REMOTEPROC_TEE
bool "Remoteproc support by a TEE application"
depends on OPTEE
help
Support a remote processor that is managed by an application running in a Trusted
Execution Environment (TEE). This application is responsible for loading the remote
processor firmware image and managing its lifecycle.

It's safe to say N if the remote processor is not managed by a TEE.

config IMX_REMOTEPROC
tristate "i.MX remoteproc support"
depends on ARCH_MXC
Expand Down
1 change: 1 addition & 0 deletions drivers/remoteproc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ remoteproc-y += remoteproc_sysfs.o
remoteproc-y += remoteproc_virtio.o
remoteproc-y += remoteproc_elf_loader.o
obj-$(CONFIG_REMOTEPROC_CDEV) += remoteproc_cdev.o
obj-$(CONFIG_REMOTEPROC_TEE) += remoteproc_tee.o
obj-$(CONFIG_IMX_REMOTEPROC) += imx_rproc.o
obj-$(CONFIG_IMX_DSP_REMOTEPROC) += imx_dsp_rproc.o
obj-$(CONFIG_INGENIC_VPU_RPROC) += ingenic_rproc.o
Expand Down
52 changes: 52 additions & 0 deletions drivers/remoteproc/remoteproc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,52 @@ void *rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem)
}
EXPORT_SYMBOL(rproc_da_to_va);

/**
* rproc_pa_to_va() - lookup the kernel virtual address for a physical address of a remoteproc
* memory
*
* @rproc: handle of a remote processor
* @pa: remoteproc physical address
* @len: length of the memory region @pa is pointing to
* @is_iomem: optional pointer filled in to indicate if @da is iomapped memory
*
* This function is a helper function similar to rproc_da_to_va() but it deals with physical
* addresses instead of device addresses.
*
* Return: a valid kernel address on success or NULL on failure
*/
void *rproc_pa_to_va(struct rproc *rproc, phys_addr_t pa, size_t len, bool *is_iomem)
{
struct rproc_mem_entry *carveout;
void *ptr = NULL;

list_for_each_entry(carveout, &rproc->carveouts, node) {
int offset = pa - carveout->dma;

/* Verify that carveout is allocated */
if (!carveout->va)
continue;

/* try next carveout if da is too small */
if (offset < 0)
continue;

/* try next carveout if da is too large */
if (offset + len > carveout->len)
continue;

ptr = carveout->va + offset;

if (is_iomem)
*is_iomem = carveout->is_iomem;

break;
}

return ptr;
}
EXPORT_SYMBOL(rproc_pa_to_va);

/**
* rproc_find_carveout_by_name() - lookup the carveout region by a name
* @rproc: handle of a remote processor
Expand Down Expand Up @@ -1811,6 +1857,8 @@ static int rproc_boot_recovery(struct rproc *rproc)

/* boot the remote processor up again */
ret = rproc_start(rproc, firmware_p);
if (ret)
rproc_release_fw(rproc);

release_firmware(firmware_p);

Expand Down Expand Up @@ -1952,6 +2000,8 @@ int rproc_boot(struct rproc *rproc)
}

ret = rproc_fw_boot(rproc, firmware_p);
if (ret)
rproc_release_fw(rproc);

release_firmware(firmware_p);
}
Expand Down Expand Up @@ -2021,6 +2071,8 @@ int rproc_shutdown(struct rproc *rproc)

rproc_disable_iommu(rproc);

rproc_release_fw(rproc);

/* Free the copy of the resource table */
kfree(rproc->cached_table);
rproc->cached_table = NULL;
Expand Down
6 changes: 6 additions & 0 deletions drivers/remoteproc/remoteproc_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,10 @@ bool rproc_u64_fit_in_size_t(u64 val)
return (val <= (size_t) -1);
}

static inline void rproc_release_fw(struct rproc *rproc)
{
if (rproc->ops->release_fw)
rproc->ops->release_fw(rproc);
}

#endif /* REMOTEPROC_INTERNAL_H */
Loading