drivers/sandbox: Introduce a simplified remoteproc framework
v2 cover drivers/sandbox: Introduce a simplified remoteproc framework
Many System on Chip(SoC) solutions are complex with multiple processors on the same die dedicated to either general purpose of specialized functions. Many examples do exist in today's SoCs from various vendors. Typical examples are micro controllers such as an ARM M3/M0 doing a offload of specific function such as event integration or power management or controlling camera etc.
Traditionally, the responsibility of loading up such a processor with a firmware and communication has been with a High Level Operating System(HLOS) such as Linux. However, there exists classes of products where Linux would need to expect services from such a processor or the delay of Linux and operating system being able to load up such a firmware is unacceptable.
The intent here is to introduce a simplified remoteproc framework which can then be used to provide basic services to these remote processors.
Series is based on:
master 79c884d7e449 Merge git://git.denx.de/u-boot-x86
Changes in V2:
- review comments from v1 incorporated
- dm test included (patch #4 is new)
V1:
http://lists.denx.de/pipermail/u-boot/2015-August/225085.html
Quick test log:
http://pastebin.ubuntu.com/12212006/
Nishanth Menon (4):
drivers: Introduce a simplified remoteproc framework
remoteproc: Introduce a sandbox dummy driver
sandbox: Introduce dummy remoteproc nodes
test: Add basic tests for remoteproc
arch/sandbox/dts/test.dts | 13 + common/Kconfig | 5 + common/Makefile | 1 + common/cmd_remoteproc.c | 281 ++++++++++++ configs/sandbox_defconfig | 2 + doc/device-tree-bindings/remoteproc/remoteproc.txt | 14 + doc/driver-model/remoteproc-framework.txt | 168 ++++++++ drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/remoteproc/Kconfig | 24 ++ drivers/remoteproc/Makefile | 10 + drivers/remoteproc/rproc-uclass.c | 472 +++++++++++++++++++++ drivers/remoteproc/sandbox_testproc.c | 336 +++++++++++++++ include/dm/uclass-id.h | 1 + include/remoteproc.h | 102 +++++ test/dm/Makefile | 1 + test/dm/remoteproc.c | 67 +++ 17 files changed, 1500 insertions(+) create mode 100644 common/cmd_remoteproc.c create mode 100644 doc/device-tree-bindings/remoteproc/remoteproc.txt create mode 100644 doc/driver-model/remoteproc-framework.txt create mode 100644 drivers/remoteproc/Kconfig create mode 100644 drivers/remoteproc/Makefile create mode 100644 drivers/remoteproc/rproc-uclass.c create mode 100644 drivers/remoteproc/sandbox_testproc.c create mode 100644 include/remoteproc.h create mode 100644 test/dm/remoteproc.c
Signature · 1 line
2.1.4
PATCH v2 1/4 drivers: Introduce a simplified remoteproc framework
Many System on Chip(SoC) solutions are complex with multiple processors on the same die dedicated to either general purpose of specialized functions. Many examples do exist in today's SoCs from various vendors. Typical examples are micro controllers such as an ARM M3/M0 doing a offload of specific function such as event integration or power management or controlling camera etc.
Traditionally, the responsibility of loading up such a processor with a firmware and communication has been with a High Level Operating System(HLOS) such as Linux. However, there exists classes of products where Linux would need to expect services from such a processor or the delay of Linux and operating system being able to load up such a firmware is unacceptable.
To address these needs, we need some minimal capability to load such a system and ensure it is started prior to an Operating System(Linux or any other) is started up.
NOTE: This is NOT meant to be a solve-all solution, instead, it tries to address certain class of SoCs and products that need such a solution.
A very simple model is introduced here as part of the initial support that supports microcontrollers with internal memory (no MMU, no execution from external memory, or specific image format needs). This basic framework can then (hopefully) be extensible to other complex SoC processor support as need be.
---
Changes in V2:
- review comments incorporated from v1
V1: https://patchwork.ozlabs.org/patch/510198/
common/Kconfig | 5 + common/Makefile | 1 + common/cmd_remoteproc.c | 281 ++++++++++++ doc/device-tree-bindings/remoteproc/remoteproc.txt | 14 + doc/driver-model/remoteproc-framework.txt | 168 ++++++++ drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/remoteproc/Kconfig | 15 + drivers/remoteproc/Makefile | 7 + drivers/remoteproc/rproc-uclass.c | 472 +++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/remoteproc.h | 102 +++++ 12 files changed, 1069 insertions(+) create mode 100644 common/cmd_remoteproc.c create mode 100644 doc/device-tree-bindings/remoteproc/remoteproc.txt create mode 100644 doc/driver-model/remoteproc-framework.txt create mode 100644 drivers/remoteproc/Kconfig create mode 100644 drivers/remoteproc/Makefile create mode 100644 drivers/remoteproc/rproc-uclass.c create mode 100644 include/remoteproc.h
common/Kconfig +5 -0
@@ -344,6 +344,11 @@ config CMD_FPGA help FPGA support. +config CMD_REMOTEPROC + bool "remoteproc" + depends on REMOTEPROC + help + Support for Remote Processor control endmenu
common/Makefile +1 -0
@@ -154,6 +154,7 @@ obj-$(CONFIG_CMD_PXE) += cmd_pxe.o obj-$(CONFIG_CMD_READ) += cmd_read.o obj-$(CONFIG_CMD_REGINFO) += cmd_reginfo.o obj-$(CONFIG_CMD_REISER) += cmd_reiser.o +obj-$(CONFIG_CMD_REMOTEPROC) += cmd_remoteproc.o obj-$(CONFIG_SANDBOX) += cmd_host.o obj-$(CONFIG_CMD_SATA) += cmd_sata.o obj-$(CONFIG_CMD_SF) += cmd_sf.o
common/cmd_remoteproc.c new file +281 -0
281 lines not on this page · raw message
doc/device-tree-bindings/remoteproc/remoteproc.txt new file +14 -0
@@ -0,0 +1,14 @@ +Remote Processor uclass + +Binding: + +Remoteproc devices shall have compatible corresponding to thier +drivers. However the following generic properties will be supported + +Optional Properties: +- remoteproc-name: a string, used if provided to describe the processor. + This must be unique in an operational system. +- remoteproc-internal-memory-mapped: a bool, indicates that the remote + processor has internal memory that it uses to execute code and store + data. Such a device is not expected to have a MMU. If no type property + is provided, the device is assumed to map to such a model.
doc/driver-model/remoteproc-framework.txt new file +168 -0
168 lines not on this page · raw message
drivers/Kconfig +2 -0
@@ -58,6 +58,8 @@ source "drivers/dma/Kconfig" source "drivers/crypto/Kconfig" +source "drivers/remoteproc/Kconfig" + source "drivers/thermal/Kconfig" endmenu
drivers/Makefile +1 -0
@@ -58,6 +58,7 @@ obj-y += pwm/ obj-y += input/ # SOC specific infrastructure drivers. obj-y += soc/ +obj-$(CONFIG_REMOTEPROC) += remoteproc/ obj-y += thermal/ endif
drivers/remoteproc/Kconfig new file +15 -0
@@ -0,0 +1,15 @@ +# +# (C) Copyright 2015 +# Texas Instruments Incorporated - http://www.ti.com/ +# SPDX-License-Identifier: GPL-2.0+ +# + +menu "Remote Processor drivers" + +# REMOTEPROC gets selected by drivers as needed +# All users should depend on DM +config REMOTEPROC + bool + depends on DM + +endmenu
drivers/remoteproc/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# +# (C) Copyright 2015 +# Texas Instruments Incorporated - http://www.ti.com/ +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-$(CONFIG_REMOTEPROC) += rproc-uclass.o
drivers/remoteproc/rproc-uclass.c new file +472 -0
472 lines not on this page · raw message
include/dm/uclass-id.h +1 -0
@@ -47,6 +47,7 @@ enum uclass_id {UCLASS_PMIC ,/* PMIC I/O device */ UCLASS_REGULATOR ,/* Regulator device */ UCLASS_RESET ,/* Reset device */ +UCLASS_REMOTEPROC ,/* Remote Processor device */ UCLASS_RTC ,/* Real time clock device */ UCLASS_SERIAL ,/* Serial UART */ UCLASS_SPI, /* SPI bus */
include/remoteproc.h new file +102 -0
102 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 1/4 drivers: Introduce a simplified remoteproc framework
Hi Nishanth,
Quoted 27 lines · Nishanth Menon
Many System on Chip(SoC) solutions are complex with multiple processors on the same die dedicated to either general purpose of specialized functions. Many examples do exist in today's SoCs from various vendors. Typical examples are micro controllers such as an ARM M3/M0 doing a offload of specific function such as event integration or power management or controlling camera etc.
Traditionally, the responsibility of loading up such a processor with a firmware and communication has been with a High Level Operating System(HLOS) such as Linux. However, there exists classes of products where Linux would need to expect services from such a processor or the delay of Linux and operating system being able to load up such a firmware is unacceptable.
To address these needs, we need some minimal capability to load such a system and ensure it is started prior to an Operating System(Linux or any other) is started up.
NOTE: This is NOT meant to be a solve-all solution, instead, it tries to address certain class of SoCs and products that need such a solution.
A very simple model is introduced here as part of the initial support that supports microcontrollers with internal memory (no MMU, no execution from external memory, or specific image format needs). This basic framework can then (hopefully) be extensible to other complex SoC processor support as need be.
Quoted 4 lines
Signed-off-by Nishanth Menon <[email protected]>---
Changes in V2:
- review comments incorporated from v1
Ah yes, but which ones?!
Quoted 24 lines
V1: https://patchwork.ozlabs.org/patch/510198/
common/Kconfig | 5 + common/Makefile | 1 + common/cmd_remoteproc.c | 281 ++++++++++++ doc/device-tree-bindings/remoteproc/remoteproc.txt | 14 + doc/driver-model/remoteproc-framework.txt | 168 ++++++++ drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/remoteproc/Kconfig | 15 + drivers/remoteproc/Makefile | 7 + drivers/remoteproc/rproc-uclass.c | 472 +++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/remoteproc.h | 102 +++++ 12 files changed, 1069 insertions(+) create mode 100644 common/cmd_remoteproc.c create mode 100644 doc/device-tree-bindings/remoteproc/remoteproc.txt create mode 100644 doc/driver-model/remoteproc-framework.txt create mode 100644 drivers/remoteproc/Kconfig create mode 100644 drivers/remoteproc/Makefile create mode 100644 drivers/remoteproc/rproc-uclass.c create mode 100644 include/remoteproc.h
[snip]
A few nits below.
Quoted 25 lines
include/dm/uclass-id.h +1
-0@@ -47,6 +47,7 @@ enum uclass_id {UCLASS_PMIC ,/* PMIC I/O device */ UCLASS_REGULATOR ,/* Regulator device */ UCLASS_RESET ,/* Reset device */ +UCLASS_REMOTEPROC ,/* Remote Processor device */ UCLASS_RTC ,/* Real time clock device */ UCLASS_SERIAL ,/* Serial UART */ UCLASS_SPI, /* SPI bus */include/remoteproc.h new file +7
-0@@ -0,0 +1,102 @@ +/* +* (C) Copyright 2015 +* Texas Instruments Incorporated - http://www.ti.com/ +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef _RPROC_H_
include/remoteproc.h line 17
Quoted 10 lines
include/remoteproc.h new file +10
-0+#define _RPROC_H_ + +/* +* XXX XXX XXX +* *IMPORTANT* NOTE: THE PLATFORM DATA SUPPORT IS NOT MEANT FOR USE WITH NEWER +* PLATFORMS. THIS IS MEANT ONLY FOR LEGACY DEVICES. THIS MODE OF +* INITIALIZATION *WILL* BE EVENTUALLY REMOVED ONCE ALL NECESSARY +* PLATFORMS HAVE MOVED TO DM/FDT. +* XXX XXX XXX +*/
This can be lower case and you should remove the XXXX stuff.
Quoted 63 lines
include/remoteproc.h new file +63
-0+#include <dm/platdata.h> /* For platform data support - non dt world */ + +/** +* enum rproc_mem_type - What type of memory model does the rproc use +* @RPROC_INTERNAL_MEMORY_MAPPED: Remote processor uses own memory and is memory +* mapped to the host processor over an address range. +* +* Please note that this is an enumeration of memory model of different types +* of remote processors. Few of the remote processors do have own internal +* memories, while others use external memory for instruction and data. +*/ +enum rproc_mem_type { +RPROC_INTERNAL_MEMORY_MAPPED =0 , +}; + +/** +* struct dm_rproc_uclass_pdata - platform data for a CPU +* @name: Platform-specific way of naming the Remote proc +* @mem_type: one of 'enum rproc_mem_type' +* @driver_plat_data: driver specific platform data that may be needed. +* +* This can be accessed with dev_get_uclass_platdata() for any UCLASS_REMOTEPROC +* device. +* +*/ +struct dm_rproc_uclass_pdata { +const char *name; +enum rproc_mem_type mem_type; +void *driver_plat_data; +}; + +/** +* struct dm_rproc_ops - Operations that are provided by remote proc driver +* @init: Initialize the remoteproc device invoked after probe (optional) +* Return 0 on success, -ve error on fail +* @load: Load the remoteproc device using data provided(mandatory) +* This takes the following additional arguments. +* addr- Address of the binary image to be loaded +* size- Size of the binary image to be loaded +* Return 0 on success, -ve error on fail +* @start: Start the remoteproc device (mandatory) +* Return 0 on success, -ve error on fail +* @stop: Stop the remoteproc device (optional) +* Return 0 on success, -ve error on fail +* @reset: Reset the remote proc device (optional) +* Return 0 on success, -ve error on fail +* @is_running: Check if the remote processor is running(optional) +* Return 0 on success, 1 if not running, -ve on others errors +* @ping: Ping the remote device for basic communication check(optional) +* Return 0 on success, 1 if not responding, -ve on other errors +*/ +struct dm_rproc_ops { +int (*init)(struct udevice *dev); +int (*load)(struct udevice *dev,ulong addr,ulong size); +int (*start)(struct udevice *dev); +int (*stop)(struct udevice *dev); +int (*reset)(struct udevice *dev); +int (*is_running)(struct udevice *dev); +int (*ping)(struct udevice *dev); +}; + +/* Accessor */ +#define rproc_get_ops (dev) ((struct dm_rproc_ops *)(dev)->driver->ops)
include/remoteproc.h line 90
Quoted 10 lines
include/remoteproc.h new file +10
-0+ +#ifdef CONFIG_REMOTEPROC +int rproc_init (void ); +bool rproc_is_initialized (void ); +int rproc_load (int id,ulong addr,ulong size); +int rproc_start (int id); +int rproc_stop (int id); +int rproc_reset (int id); +int rproc_ping (int id); +int rproc_is_running (int id);
Can you move your function comments to here? This where you define your API, and it is the file that people will read.
Quoted 13 lines
include/remoteproc.h new file +12
-1+#else +static inline int rproc_init (void ) {return -ENOSYS ; } +static inline bool rproc_is_initialized (void ) {return false; } +static inline int rproc_load (int id,ulong addr,ulong size) {return -ENOSYS ; } +static inline int rproc_start (int id) {return -ENOSYS ; } +static inline int rproc_stop (int id) {return -ENOSYS ; } +static inline int rproc_reset (int id) {return -ENOSYS ; } +static inline int rproc_ping (int id) {return -ENOSYS ; } +static inline int rproc_is_running (int id) {return -ENOSYS ; } +#endif + +#endif /* _RPROC_H_ */ --
Quoted 2 lines
2.1.4
Regards,
Simon
PATCH v2 1/4 drivers: Introduce a simplified remoteproc framework
On 21:46-20150901, Simon Glass wrote:
Hi Simon,
Apologies on a delayed response.
[...]
Quoted 4 lines
Quoted 2 lines
Changes in V2:
- review comments incorporated from v1Ah yes, but which ones?!
Hopefully all of them - I'd normally list up the details, but the changes were a little too many in the case of v2.. [...]
Quoted 4 lines
Quoted 1 line
[snip]
Reviewed-by Simon Glass <[email protected]>
Thanks. Will post next rev fixing the nits and picking up your reviewed-by tag.
Quoted 2 lines
A few nits below.
Thanks once again for your patience and review.
Quoted 11 lines
include/remoteproc.h line 17
Quoted 9 lines
include/remoteproc.h new file +9
-0+ +/* +* XXX XXX XXX +* *IMPORTANT* NOTE: THE PLATFORM DATA SUPPORT IS NOT MEANT FOR USE WITH NEWER +* PLATFORMS. THIS IS MEANT ONLY FOR LEGACY DEVICES. THIS MODE OF +* INITIALIZATION *WILL* BE EVENTUALLY REMOVED ONCE ALL NECESSARY +* PLATFORMS HAVE MOVED TO DM/FDT. +* XXX XXX XXX +*/ This can be lower case and you should remove the XXXX stuff.
Will do so in the next rev.
Quoted 7 lines
Quoted 7 lines
include/remoteproc.h new file +7
-0+/* Accessor */ +#define rproc_get_ops (dev) ((struct dm_rproc_ops *)(dev)->driver->ops) + +#ifdef CONFIG_REMOTEPROC +int rproc_init (void ); +bool rproc_is_initialized (void ); +int rproc_load (int id,ulong addr,ulong size);
Quoted 8 lines
include/remoteproc.h line 90
Quoted 5 lines
include/remoteproc.h new file +5
-0+int rproc_start (int id); +int rproc_stop (int id); +int rproc_reset (int id); +int rproc_ping (int id); +int rproc_is_running (int id);Can you move your function comments to here? This where you define your API, and it is the file that people will read.
Will do so as well.
Signature · 2 lines
Regards, Nishanth Menon
PATCH v2 2/4 remoteproc: Introduce a sandbox dummy driver
In reply to Nishanth MenonIntroduce a dummy driver for sandbox that allows us to verify basic functionality. This is not meant to do anything functional - but is more or less meant as a framework plumbing debug helper.
The sandbox remoteproc driver maintains absolutey no states and is a simple driver which just is filled with empty hooks. Idea being to give an approximate idea to implement own remoteproc driver using this as a template.
---
Changes in V2:
- review comments incorporated from v1
V1: https://patchwork.ozlabs.org/patch/510197/
drivers/remoteproc/Kconfig | 9 + drivers/remoteproc/Makefile | 3 + drivers/remoteproc/sandbox_testproc.c | 336 ++++++++++++++++++++++++++++++++++ 3 files changed, 348 insertions(+) create mode 100644 drivers/remoteproc/sandbox_testproc.c
drivers/remoteproc/Kconfig +9 -0
@@ -12,4 +12,13 @@ config REMOTEPROC bool depends on DM +# Please keep the configuration alphabetically sorted. +config REMOTEPROC_SANDBOX + bool "Support for Test processor for Sandbox" + select REMOTEPROC + depends on DM + depends on SANDBOX + help + Say 'y' here to add support for test processor which does dummy + operations for sandbox platform. endmenu
drivers/remoteproc/Makefile +3 -0
@@ -5,3 +5,6 @@ # obj-$(CONFIG_REMOTEPROC) += rproc-uclass.o + +# Remote proc drivers - Please keep this list alphabetically sorted. +obj-$(CONFIG_REMOTEPROC_SANDBOX) += sandbox_testproc.o
drivers/remoteproc/sandbox_testproc.c new file +336 -0
336 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 2/4 remoteproc: Introduce a sandbox dummy driver
Hi Nishanth,
Quoted 14 lines · Nishanth Menon
Introduce a dummy driver for sandbox that allows us to verify basic functionality. This is not meant to do anything functional - but is more or less meant as a framework plumbing debug helper.
The sandbox remoteproc driver maintains absolutey no states and is a simple driver which just is filled with empty hooks. Idea being to give an approximate idea to implement own remoteproc driver using this as a template.
Signed-off-by Nishanth Menon <[email protected]>---
Changes in V2:
- review comments incorporated from v1
Quoted 7 lines
V1: https://patchwork.ozlabs.org/patch/510197/
drivers/remoteproc/Kconfig | 9 + drivers/remoteproc/Makefile | 3 + drivers/remoteproc/sandbox_testproc.c | 336 ++++++++++++++++++++++++++++++++++ 3 files changed, 348 insertions(+) create mode 100644 drivers/remoteproc/sandbox_testproc.c
Nit below.
Quoted 353 lines
drivers/remoteproc/Kconfig +9
-0@@ -12,4 +12,13 @@ config REMOTEPROC bool depends on DM +# Please keep the configuration alphabetically sorted. +config REMOTEPROC_SANDBOX + bool "Support for Test processor for Sandbox" + select REMOTEPROC + depends on DM + depends on SANDBOX + help + Say 'y' here to add support for test processor which does dummy + operations for sandbox platform. endmenudrivers/remoteproc/Makefile +3
-0@@ -5,3 +5,6 @@ # obj-$(CONFIG_REMOTEPROC) += rproc-uclass.o + +# Remote proc drivers - Please keep this list alphabetically sorted. +obj-$(CONFIG_REMOTEPROC_SANDBOX) += sandbox_testproc.odrivers/remoteproc/sandbox_testproc.c new file +317
-0@@ -0,0 +1,336 @@ +/* +* (C) Copyright 2015 +* Texas Instruments Incorporated - http://www.ti.com/ +* SPDX-License-Identifier: GPL-2.0+ +*/ +#define pr_fmt (fmt) "%s: " fmt, __func__ +#include <common.h> +#include <dm.h> +#include <errno.h> +#include <remoteproc.h> + +/** +* enum sandbox_state - different device states +* @sb_booted: Entry condition, just booted +* @sb_init: Initialized (basic environment is ready) +* @sb_reset: Held in reset (accessible, but not running) +* @sb_loaded: Loaded with image (but not running) +* @sb_running: Processor is running +*/ +enum sandbox_state { + sb_booted, + sb_init, + sb_reset, + sb_loaded, + sb_running +}; + +/** +* struct sandbox_test_devdata - private data per device +* @current_state: device current state +*/ +struct sandbox_test_devdata { +enum sandbox_state current_state; +}; + +/** +* sandbox_dev_move_to_state() - statemachine for our dummy device +* @dev: device to switch state +* @next_state: next proposed state +* +* This tries to follow the following statemachine: +* Entry +* | +* v +* +-------+ +* +---+ init | +* | | | <---------------------+ +* | +-------+ | +* | | +* | | +* | +--------+ | +* Load| | reset | | +* | | | <----------+ | +* | +--------+ | | +* | |Load | | +* | | | | +* | +----v----+ reset | | +* +-> | | (opt) | | +* | Loaded +-----------+ | +* | | | +* +----+----+ | +* | Start | +* +---v-----+ (opt) | +* +->| Running | Stop | +* Ping +- | +--------------------+ +* (opt) +---------+ +* +* (is_running does not change state) +* +* Return: 0 when valid state transition is seen, else returns -EINVAL +*/ +static int sandbox_dev_move_to_state (struct udevice *dev, +enum sandbox_state next_state) +{ +struct sandbox_test_devdata *ddata =dev_get_priv (dev); + +/* No state transition is OK */ +if (ddata->current_state == next_state) +return 0 ; + +debug ("current_state=%d, next_state=%d\n" , ddata->current_state, + next_state); +switch (ddata->current_state) { +case sb_booted: +if (next_state == sb_init) + goto ok_state; +break ; + +case sb_init: +if (next_state == sb_reset || next_state == sb_loaded) + goto ok_state; +break ; + +case sb_reset: +if (next_state == sb_loaded || next_state == sb_init) + goto ok_state; +break ; + +case sb_loaded: +if (next_state == sb_reset || next_state == sb_init || + next_state == sb_running) + goto ok_state; +break ; + +case sb_running: +if (next_state == sb_reset || next_state == sb_init) + goto ok_state; +break ; + }; +return -EINVAL ; + +ok_state: + ddata->current_state = next_state; +return 0 ; +} + +/** +* sandbox_testproc_probe() - basic probe function +* @dev: test proc device that is being probed. +* +* Return: 0 if all went ok, else return appropriate error +*/ +static int sandbox_testproc_probe (struct udevice *dev) +{ +struct dm_rproc_uclass_pdata *uc_pdata; +struct sandbox_test_devdata *ddata; +int ret; + + uc_pdata =dev_get_uclass_platdata (dev); + ddata =dev_get_priv (dev); +if (!ddata) { +debug ("%s: platform private data missing\n" , uc_pdata->name); +return -EINVAL ; + } + ret =sandbox_dev_move_to_state (dev, sb_booted); +debug ("%s: called(%d)\n" , uc_pdata->name, ret); + +return ret; +} + +/** +* sandbox_testproc_init() - Simple initialization function +* @dev: device to operate upon +* +* Return: 0 if all went ok, else return appropriate error +*/ +static int sandbox_testproc_init (struct udevice *dev) +{ +struct dm_rproc_uclass_pdata *uc_pdata; +int ret; + + uc_pdata =dev_get_uclass_platdata (dev); + + ret =sandbox_dev_move_to_state (dev, sb_init); + +debug ("%s: called(%d)\n" , uc_pdata->name, ret); +if (ret) +debug ("%s init failed\n" , uc_pdata->name); + +return ret; +} + +/** +* sandbox_testproc_reset() - Reset the remote processor +* @dev: device to operate upon +* +* Return: 0 if all went ok, else return appropriate error +*/ +static int sandbox_testproc_reset (struct udevice *dev) +{ +struct dm_rproc_uclass_pdata *uc_pdata; +int ret; + + uc_pdata =dev_get_uclass_platdata (dev); + + ret =sandbox_dev_move_to_state (dev, sb_reset); + +debug ("%s: called(%d)\n" , uc_pdata->name, ret); + +if (ret) +debug ("%s reset failed\n" , uc_pdata->name); +return ret; +} + +/** +* sandbox_testproc_load() - (replace: short desc) +* @dev: device to operate upon +* @addr: Address of the binary image to load +* @size: Size (in bytes) of the binary image to load +* +* Return: 0 if all went ok, else return appropriate error +*/ +static int sandbox_testproc_load (struct udevice *dev,ulong addr,ulong size) +{ +struct dm_rproc_uclass_pdata *uc_pdata; +int ret; + + uc_pdata =dev_get_uclass_platdata (dev); + + ret =sandbox_dev_move_to_state (dev, sb_loaded); + +debug ("%s: called(%d) Loading to %08lX %lu size\n" , + uc_pdata->name, ret, addr, size); + +if (ret) +debug ("%s load failed\n" , uc_pdata->name); +return ret; +} + +/** +* sandbox_testproc_start() - Start the remote processor +* @dev: device to operate upon +* +* Return: 0 if all went ok, else return appropriate error +*/ +static int sandbox_testproc_start (struct udevice *dev) +{ +struct dm_rproc_uclass_pdata *uc_pdata; +int ret; + + uc_pdata =dev_get_uclass_platdata (dev); + + ret =sandbox_dev_move_to_state (dev, sb_running); + +debug ("%s: called(%d)\n" , uc_pdata->name, ret); + +if (ret) +debug ("%s start failed\n" , uc_pdata->name); +return ret; +} + +/** +* sandbox_testproc_stop() - Stop the remote processor +* @dev: device to operate upon +* +* Return: 0 if all went ok, else return appropriate error +*/ +static int sandbox_testproc_stop (struct udevice *dev) +{ +struct dm_rproc_uclass_pdata *uc_pdata; +int ret; + + uc_pdata =dev_get_uclass_platdata (dev); + + ret =sandbox_dev_move_to_state (dev, sb_init); + +debug ("%s: called(%d)\n" , uc_pdata->name, ret); + +if (ret) +debug ("%s stop failed\n" , uc_pdata->name); +return ret; +} + +/** +* sandbox_testproc_is_running() - Check if remote processor is running +* @dev: device to operate upon +* +* Return: 0 if running, 1 if not running +*/ +static int sandbox_testproc_is_running (struct udevice *dev) +{ +struct dm_rproc_uclass_pdata *uc_pdata; +struct sandbox_test_devdata *ddata; +int ret =1 ; + + uc_pdata =dev_get_uclass_platdata (dev); + ddata =dev_get_priv (dev); + +if (ddata->current_state == sb_running) + ret =0 ; +debug ("%s: called(%d)\n" , uc_pdata->name, ret); + +return ret; +} + +/** +* sandbox_testproc_ping() - Try pinging remote processor +* @dev: device to operate upon +* +* Return: 0 if running, -EINVAL if not running +*/ +static int sandbox_testproc_ping (struct udevice *dev) +{ +struct dm_rproc_uclass_pdata *uc_pdata; +struct sandbox_test_devdata *ddata; +int ret; + + uc_pdata =dev_get_uclass_platdata (dev); + ddata =dev_get_priv (dev); + +if (ddata->current_state == sb_running) + ret =0 ; +else + ret = -EINVAL ; + +debug ("%s: called(%d)\n" , uc_pdata->name, ret); +if (ret) +debug ("%s: No response.(Not started?)\n" , uc_pdata->name); + +return ret; +} + +static const struct dm_rproc_ops sandbox_testproc_ops = { + .init = sandbox_testproc_init, + .reset = sandbox_testproc_reset, + .load = sandbox_testproc_load, + .start = sandbox_testproc_start, + .stop = sandbox_testproc_stop, + .is_running = sandbox_testproc_is_running, + .ping = sandbox_testproc_ping, +}; + +static const struct udevice_id sandbox_ids[] = { + {.compatible ="sandbox,test-processor" }, + {} +}; +
drivers/remoteproc/sandbox_testproc.c line 327
Quoted 10 lines
drivers/remoteproc/sandbox_testproc.c new file +10
-0+U_BOOT_DRIVER (sandbox_testproc) = { + .name ="sandbox_test_proc" , + .of_match = sandbox_ids, + .id =UCLASS_REMOTEPROC , + .ops = &sandbox_testproc_ops, + .probe = sandbox_testproc_probe, + .priv_auto_alloc_size =sizeof (struct sandbox_test_devdata ), +}; + +/* XXX: THIS MUST GO AWAY ALONG WITH NON-DT support.. */
/* TODO(your at email.com): Remove this along with... */
Quoted 10 lines
drivers/remoteproc/sandbox_testproc.c new file +9
-1+static struct dm_rproc_uclass_pdata proc_3_test = { + .name ="proc_3_legacy" , + .mem_type =RPROC_INTERNAL_MEMORY_MAPPED , +}; + +U_BOOT_DEVICE (proc_3_demo) = { + .name ="sandbox_test_proc" , + .platdata = &proc_3_test, +}; --
Quoted 2 lines
2.1.4
Regards,
Simon
PATCH v2 2/4 remoteproc: Introduce a sandbox dummy driver
Quoted 2 lines · Simon Glass
On 27 August 2015 at 22:07, Nishanth Menon <[email protected]> wrote:
[...]
Quoted 1 line
Reviewed-by Simon Glass <[email protected]>
Thanks. will update and post the next rev with the mentioned changes incorporated.
Quoted 2 lines
Nit below.
[...]
Quoted 4 lines
drivers/remoteproc/sandbox_testproc.c line 327
Quoted 2 lines
drivers/remoteproc/sandbox_testproc.c new file +2
-0+ +/* XXX: THIS MUST GO AWAY ALONG WITH NON-DT support.. */ /* TODO(your at email.com): Remove this along with... */
OK. Will add the details.
Signature · 2 lines
Regards, Nishanth Menon
PATCH v2 3/4 sandbox: Introduce dummy remoteproc nodes
In reply to Nishanth MenonIntroduce dummy devices for sandbox remoteproc device and enable it by default
---
Changes in V2:
- review comments incorporated from V1.
V1: https://patchwork.ozlabs.org/patch/510196/
arch/sandbox/dts/test.dts | 13 +++++++++++++ configs/sandbox_defconfig | 2 ++ 2 files changed, 15 insertions(+)
arch/sandbox/dts/test.dts +13 -0
@@ -12,6 +12,8 @@ eth5 = ð_5; i2c0 = "/i2c at 0"; pci0 = &pci; + remoteproc1 = &rproc_1; + remoteproc2 = &rproc_2; rtc0 = &rtc_0; rtc1 = &rtc_1; spi0 = "/spi at 0";
@@ -226,6 +228,17 @@ compatible = "sandbox,reset"; }; + rproc_1: rproc at 1 { + compatible = "sandbox,test-processor"; + remoteproc-name = "remoteproc-test-dev1"; + }; + + rproc_2: rproc at 2 { + compatible = "sandbox,test-processor"; + internal-memory-mapped; + remoteproc-name = "remoteproc-test-dev2"; + }; + spi at 0 { #address-cells = <1>; #size-cells = <0>;
configs/sandbox_defconfig +2 -0
@@ -54,3 +54,5 @@ CONFIG_UNIT_TEST=y CONFIG_UT_TIME=y CONFIG_UT_DM=y CONFIG_UT_ENV=y +CONFIG_REMOTEPROC_SANDBOX=y +CONFIG_CMD_REMOTEPROC=y
Signature · 1 line
2.1.4
PATCH v2 3/4 sandbox: Introduce dummy remoteproc nodes
Quoted 6 lines · Nishanth Menon
Introduce dummy devices for sandbox remoteproc device and enable it by default
Signed-off-by Nishanth Menon <[email protected]>---
Quoted 8 lines
Changes in V2:
- review comments incorporated from V1.V1: https://patchwork.ozlabs.org/patch/510196/
arch/sandbox/dts/test.dts | 13 +++++++++++++ configs/sandbox_defconfig | 2 ++ 2 files changed, 15 insertions(+)
PATCH v2 4/4 test: Add basic tests for remoteproc
In reply to Nishanth MenonUse the sandbox environment for the basic tests.
---
New patch.
test/dm/Makefile | 1 + test/dm/remoteproc.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 test/dm/remoteproc.c
test/dm/Makefile +1 -0
@@ -24,6 +24,7 @@ obj-$(CONFIG_DM_MMC) += mmc.o obj-$(CONFIG_DM_PCI) += pci.o obj-$(CONFIG_RAM) += ram.o obj-y += regmap.o +obj-$(CONFIG_REMOTEPROC) += remoteproc.o obj-$(CONFIG_RESET) += reset.o obj-$(CONFIG_DM_RTC) += rtc.o obj-$(CONFIG_DM_SPI_FLASH) += sf.o
test/dm/remoteproc.c new file +67 -0
67 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 4/4 test: Add basic tests for remoteproc
Quoted 10 lines · Nishanth Menon
Use the sandbox environment for the basic tests.
Signed-off-by Nishanth Menon <[email protected]>---
New patch.test/dm/Makefile | 1 + test/dm/remoteproc.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 test/dm/remoteproc.c
Nit below.
Quoted 66 lines
test/dm/Makefile +1
-0@@ -24,6 +24,7 @@ obj-$(CONFIG_DM_MMC) += mmc.o obj-$(CONFIG_DM_PCI) += pci.o obj-$(CONFIG_RAM) += ram.o obj-y += regmap.o +obj-$(CONFIG_REMOTEPROC) += remoteproc.o obj-$(CONFIG_RESET) += reset.o obj-$(CONFIG_DM_RTC) += rtc.o obj-$(CONFIG_DM_SPI_FLASH) += sf.otest/dm/remoteproc.c new file +47
-0@@ -0,0 +1,67 @@ +/* +* (C) Copyright 2015 +* Texas Instruments Incorporated - http://www.ti.com/ +* SPDX-License-Identifier: GPL-2.0+ +*/ +#include <common.h> +#include <dm.h> +#include <errno.h> +#include <remoteproc.h> +#include <dm/test.h> +#include <test/ut.h> +/** +* dm_test_remoteproc_base() - test the operations after initializations +* @uts: unit test state +* +* Return: 0 if test passed, else error +*/ +static int dm_test_remoteproc_base (struct unit_test_state *uts) +{ +if (!rproc_is_initialized ()) +ut_assertok (rproc_init ()); + +/* Ensure we are initialized */ +ut_asserteq (true,rproc_is_initialized ()); + + +/* platform data device 1 */ +ut_assertok (rproc_stop (0 )); +ut_assertok (rproc_reset (0 )); +/* -> invalid attempt tests.. */ +ut_asserteq (-EINVAL ,rproc_start (0 )); +ut_asserteq (-EINVAL ,rproc_ping (0 )); +/* Valid tests.. */ +ut_assertok (rproc_load (0 ,1 ,0 )); +ut_assertok (rproc_start (0 )); +ut_assertok (rproc_is_running (0 )); +ut_assertok (rproc_ping (0 )); +ut_assertok (rproc_reset (0 )); +ut_assertok (rproc_stop (0 )); + +/* dt device device 1 */ +ut_assertok (rproc_stop (1 )); +ut_assertok (rproc_reset (1 )); +ut_assertok (rproc_load (1 ,1 ,0 )); +ut_assertok (rproc_start (1 )); +ut_assertok (rproc_is_running (1 )); +ut_assertok (rproc_ping (1 ));
test/dm/remoteproc.c line 57
Quoted 10 lines
test/dm/remoteproc.c new file +10
-0+ut_assertok (rproc_reset (1 )); +ut_assertok (rproc_stop (1 )); + +/* dt device device 2 */ +ut_assertok (rproc_stop (0 )); +ut_assertok (rproc_reset (0 )); +/* -> invalid attempt tests.. */ +ut_asserteq (-EINVAL ,rproc_start (0 )); +ut_asserteq (-EINVAL ,rproc_ping (0 )); +/* Valid tests.. */
You don't need a period at the end of these comments\
test/dm/remoteproc.c line 63
Quoted 6 lines
test/dm/remoteproc.c new file +6
-0+ut_assertok (rproc_load (2 ,1 ,0 )); +ut_assertok (rproc_start (2 )); +ut_assertok (rproc_is_running (2 )); +ut_assertok (rproc_ping (2 )); +ut_assertok (rproc_reset (2 )); +ut_assertok (rproc_stop (2 ));
Would it be worth having a test that goes through things in the wrong sequence? It's up to you.
BTW you don't have to put all your tests in one function, e.g. if some have a different purpose you can put them in a separate function.
Quoted 7 lines
test/dm/remoteproc.c new file +4
-1+ +return 0 ; +} +DM_TEST (dm_test_remoteproc_base,DM_TESTF_SCAN_PDATA |DM_TESTF_SCAN_FDT ); --2.1.4
Regards,
Simon
PATCH v2 4/4 test: Add basic tests for remoteproc
Quoted 12 lines · Simon Glass
Quoted 10 lines · Nishanth Menon
Use the sandbox environment for the basic tests.
Signed-off-by Nishanth Menon <[email protected]>---
New patch.test/dm/Makefile | 1 + test/dm/remoteproc.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 test/dm/remoteproc.c
Quoted 4 lines
Reviewed-by Simon Glass <[email protected]>Tested-by Simon Glass <[email protected]>Nit below.
Thanks. Will fix the same in the next rev.
[...]
Quoted 10 lines
test/dm/remoteproc.c line 57
Quoted 8 lines
test/dm/remoteproc.c new file +8
-0+ +/* dt device device 2 */ +ut_assertok (rproc_stop (0 )); +ut_assertok (rproc_reset (0 )); +/* -> invalid attempt tests.. */ +ut_asserteq (-EINVAL ,rproc_start (0 )); +ut_asserteq (-EINVAL ,rproc_ping (0 )); +/* Valid tests.. */ You don't need a period at the end of these comments\
Yep. Will fix.
Quoted 10 lines
test/dm/remoteproc.c line 63
Quoted 7 lines
test/dm/remoteproc.c new file +6
-0+ut_assertok (rproc_load (2 ,1 ,0 )); +ut_assertok (rproc_start (2 )); +ut_assertok (rproc_is_running (2 )); +ut_assertok (rproc_ping (2 )); +ut_assertok (rproc_reset (2 )); +ut_assertok (rproc_stop (2 ));Would it be worth having a test that goes through things in the wrong sequence? It's up to you.
The current tests does attempt to perform basic sanity tests - there are invalid sequence attempts as well.
Quoted 3 lines
BTW you don't have to put all your tests in one function, e.g. if some have a different purpose you can put them in a separate function.
I agree and had started it that way, then as I started putting things together, considering the tests were simple sequence based, they were good enough to put them in the test sequence in one shot. We can definitely evolve as folks find specific needs of improvement in the future.
Signature · 2 lines
Regards, Nishanth Menon