remoteproc: add CSRatlas7 remoteproc driver
Subsystems (2)
cover remoteproc: add CSRatlas7 remoteproc driver
From: Barry Song <[email protected]>
The first two patches make remoteproc support non-slave remote processors. the last one adds CSRatlas7 support.
Wei Chen (3):
drivers:remoteproc:support predefined vq notifyid drivers:remoteproc:support always on remote processor
remoteproc: add CSRatlas7 remoteproc driver
.../bindings/remoteproc/sirf,remoteproc.txt | 33 ++ drivers/remoteproc/Kconfig | 13 + drivers/remoteproc/Makefile | 1 + drivers/remoteproc/remoteproc_core.c | 21 +- drivers/remoteproc/remoteproc_virtio.c | 8 + drivers/remoteproc/sirf_remoteproc.c | 467 +++++++++++++++++++++ include/linux/remoteproc.h | 4 +- 7 files changed, 541 insertions(+), 6 deletions(-) create mode 100644 Documentation/devicetree/bindings/remoteproc/sirf,remoteproc.txt create mode 100644 drivers/remoteproc/sirf_remoteproc.c
Signature · 1 line
1.9.1
PATCH 1/3 drivers:remoteproc:support predefined vq notifyid
From: Wei Chen <[email protected]>
In current rproc use scenario, the vq notifyid will be allocated by Linux, and write back this notifyid to RSC table to tell DSP.
But in some scenarios, we might meet the DSP predefined the vq notifyid. In these scenarios, the rproc have to read predefined vq notifyid from RSC table, and then request a same notifyid in Linux side.
--- drivers/remoteproc/remoteproc_core.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/remoteproc/remoteproc_core.c +11 -5
@@ -206,7 +206,7 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i)struct fw_rsc_vdev *rsc;dma_addr_t dma;void *va; -int ret, size, notifyid; +int ret, size, notifyid, pre_nid;/* actual size of vring (in bytes) */ size =PAGE_ALIGN (vring_size (rvring->len, rvring->align));
@@ -222,11 +222,16 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) }/* +* read predefined notifyids (via resource table) +*/ + rsc = (void *)rproc->table_ptr + rvdev->rsc_offset; + pre_nid = rsc->vring[i].notifyid; + +/* * Assign an rproc-wide unique index for this vring * TODO: assign a notifyid for rvdev updates as well -* TODO: support predefined notifyids (via resource table) */ - ret =idr_alloc (&rproc->notifyids, rvring,0 ,0 ,GFP_KERNEL ); + ret =idr_alloc (&rproc->notifyids, rvring, pre_nid,0 ,GFP_KERNEL );if (ret <0 ) {dev_err (dev,"idr_alloc failed: %d\n" , ret);dma_free_coherent (dev->parent, size, va, dma);
@@ -247,9 +252,10 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i)* set up the iommu. In this case the device address (da) will * hold the physical address and not the device address. */ - rsc = (void *)rproc->table_ptr + rvdev->rsc_offset; rsc->vring[i].da = dma; - rsc->vring[i].notifyid = notifyid; +/* If notifyid is not predefined, write back to rsc */ +if (!pre_nid) + rsc->vring[i].notifyid = notifyid;return 0 ; }
Signature · 1 line
1.9.1
PATCH 2/3 drivers:remoteproc:support always on remote processor
In reply to Barry SongFrom: Wei Chen <[email protected]>
In current rproc use scenarios, the Linux side controls the lifecycle of the remote processors, just like boot, start, shutdown.
But in some scenarios, we require the remote processors to be powered and booted before Linux bring up. In additional, we might have require the remote processors could not be shutdown, if it would be shutdown, the Linux should be shutdown too.
In above scenarios, we have make remoteproc to support always on remote processor. This kind of remote processor control its lifecycle by itself.
--- drivers/remoteproc/remoteproc_core.c | 5 +++++ drivers/remoteproc/remoteproc_virtio.c | 8 ++++++++ include/linux/remoteproc.h | 4 +++- 3 files changed, 16 insertions(+), 1 deletion(-)
drivers/remoteproc/remoteproc_core.c +5 -0
@@ -917,6 +917,10 @@ static void rproc_fw_config_virtio(const struct firmware *fw, void *context) rproc->table_csum =crc32 (0 , table, tablesz); +if (rproc->state ==RPROC_ALWAYS_ON ) { + rproc->table_ptr = table; + goto handl_res; + }/* * Create a copy of the resource table. When a virtio device starts * and calls vring_new_virtqueue() the address of the allocated vring
@@ -929,6 +933,7 @@ static void rproc_fw_config_virtio(const struct firmware *fw, void *context) rproc->table_ptr = rproc->cached_table; +handl_res:/* count the number of notify-ids */ rproc->max_notifyid =-1 ; ret = rproc_handle_resources(rproc, tablesz,
drivers/remoteproc/remoteproc_virtio.c +8 -0
@@ -138,9 +138,13 @@ static void rproc_virtio_del_vqs(struct virtio_device *vdev) {struct rproc *rproc =vdev_to_rproc (vdev); +if (rproc->state ==RPROC_ALWAYS_ON ) + goto del_vqs; +/* power down the remote processor before deleting vqs */ rproc_shutdown (rproc); +del_vqs:__rproc_virtio_del_vqs (vdev); }
@@ -160,6 +164,10 @@ static int rproc_virtio_find_vqs(struct virtio_device *vdev, unsigned nvqs, } } +/* always on rproc */ +if (rproc->state ==RPROC_ALWAYS_ON ) +return 0 ; +/* now that the vqs are all set, boot the remote processor */ ret =rproc_boot (rproc);if (ret) {
include/linux/remoteproc.h +3 -1
@@ -346,6 +346,7 @@ struct rproc_ops {* a message. * @RPROC_RUNNING: device is up and running * @RPROC_CRASHED: device has crashed; need to start recovery +* @RPROC_ALWAYS_ON: device is always on, doesn't need to power on/off. * @RPROC_LAST: just keep this one at the end * * Please note that the values of these states are used as indices
@@ -359,7 +360,8 @@ enum rproc_state {RPROC_SUSPENDED =1 ,RPROC_RUNNING =2 ,RPROC_CRASHED =3 , - RPROC_LAST = 4, +RPROC_ALWAYS_ON =4 , + RPROC_LAST = 5, };/**
Signature · 1 line
1.9.1
PATCH 3/3 remoteproc: add CSRatlas7 remoteproc driver
In reply to Barry SongFrom: Wei Chen <[email protected]>
In CSRaltas7, Cortex-A7 uses this proc to communicate with Cortex-M3. But M3 doesn't have to be a slave, it can boot indenpently or depend on Linux to load firmware for it.
we reserve a memory for data and resource descriptors in DRAM.
--- .../bindings/remoteproc/sirf,remoteproc.txt | 33 ++ drivers/remoteproc/Kconfig | 13 + drivers/remoteproc/Makefile | 1 + drivers/remoteproc/sirf_remoteproc.c | 467 +++++++++++++++++++++ 4 files changed, 514 insertions(+) create mode 100644 Documentation/devicetree/bindings/remoteproc/sirf,remoteproc.txt create mode 100644 drivers/remoteproc/sirf_remoteproc.c
Documentation/devicetree/bindings/remoteproc/sirf,remoteproc.txt new file +33 -0
@@ -0,0 +1,33 @@ +SIRF Atlas7 Remote processor Device Binding +------------------------------------------------ +1) Main node + Required properties : + + - compatible : "sirf,atlas7-rproc" + + - reg : register address of remoteproc device + + - interrupts: the irq number this rproc need to handle. + + - hwlocks: the hwlocks this rproc to used to protect data + between two processors. + + - memory-region: the memory region, which is used to store virtual + device info, fifo buffers and share memory between two processors. + + - firmware: the firmware file that will be loaded to remote processor. + +Please refer to ../reserved-memory/reserved-memory.txt for details of the +memory-region bindings. +Please refer to ../hwlock/hwlock.txt for details of the hwlock bindings. + +2) Example: + ns_m3_rproc at 0 { + compatible = "sirf,atlas7-rproc"; + reg = <0x13240108 0x4>, + <0x13240208 0x4>; + interrupts = <0 123 0>; + hwlocks = <&hwlock 0>, <&hwlock 1>; + memory-region = <&ipc_mem0>; + firmware = "RTOSDemo.bin"; + };
drivers/remoteproc/Kconfig +13 -0
@@ -77,4 +77,17 @@ config DA8XX_REMOTEPROC It's safe to say n here if you're not interested in multimedia offloading. +config SIRF_REMOTEPROC + tristate "CSR atals7 remoteproc support" + depends on ARCH_ATLAS7 + select REMOTEPROC + select RPMSG + default y + help + Say y or m here to support CSR Atlas7 Inter-Processors + Communication driver via remote processor framework. + + This can be either built-in or a loadable module. + If unsure say N. + endmenu
drivers/remoteproc/Makefile +1 -0
@@ -11,3 +11,4 @@ obj-$(CONFIG_OMAP_REMOTEPROC) += omap_remoteproc.o obj-$(CONFIG_STE_MODEM_RPROC) += ste_modem_rproc.o obj-$(CONFIG_WKUP_M3_RPROC) += wkup_m3_rproc.o obj-$(CONFIG_DA8XX_REMOTEPROC) += da8xx_remoteproc.o +obj-$(CONFIG_SIRF_REMOTEPROC) += sirf_remoteproc.o
drivers/remoteproc/sirf_remoteproc.c new file +467 -0
467 lines not on this page · raw message
Signature · 1 line
1.9.1