Make platform data as remote proc init input
authorWendy Liang <jliang@xilinx.com>
Wed, 29 Jun 2016 05:57:41 +0000 (22:57 -0700)
committerWendy Liang <jliang@xilinx.com>
Thu, 13 Oct 2016 05:01:43 +0000 (22:01 -0700)
Previously, the library relies on extern platform data variable.
This patch changes the remote processor initialization API to
have platform data as input argument and also allows each
remoteproc driver to have its own initialization implementation.

Signed-off-by: Wendy Liang <jliang@xilinx.com>
lib/common/hil.c
lib/include/openamp/hil.h
lib/include/openamp/remoteproc.h
lib/include/openamp/rpmsg.h
lib/include/openamp/rpmsg_core.h
lib/remoteproc/remoteproc.c
lib/rpmsg/remote_device.c
lib/rpmsg/rpmsg.c

index eb53e96e56a6a6ebb13080b9217117f43802620c..5f0e245c17160e2974166d03ebf19ba43da3f952 100644 (file)
@@ -66,14 +66,15 @@ extern int platform_get_processor_for_fw(char *fw_name);
  * This function creates a HIL proc instance for given CPU id and populates
  * it with platform info.
  *
+ * @param pdata  - platform data for the remote processor
  * @param cpu_id - cpu id
  *
  * @return - pointer to proc instance
  *
  */
-struct hil_proc *hil_create_proc(int cpu_id)
+struct hil_proc *hil_create_proc(void *pdata, int cpu_id)
 {
-       struct hil_proc *proc;
+       struct hil_proc *proc, *proc_data;
        struct metal_list *node;
        int status;
 
@@ -85,6 +86,12 @@ struct hil_proc *hil_create_proc(int cpu_id)
                }
        }
 
+       if (!pdata)
+               return NULL;
+       proc_data = (struct hil_proc *)pdata;
+       if (!proc_data->ops || !proc_data->ops->initialize)
+               return NULL;
+
        /* Allocate memory for proc instance */
        proc = env_allocate_memory(sizeof(struct hil_proc));
        if (!proc) {
@@ -92,7 +99,8 @@ struct hil_proc *hil_create_proc(int cpu_id)
        }
 
        /* Get HW specfic info */
-       status = platform_get_processor_info(proc, cpu_id);
+       status = proc_data->ops->initialize(pdata,
+                                 proc, cpu_id);
        if (status) {
                env_free_memory(proc);
                return NULL;
index a8d8f44d1e6f51a20da04509a30c46b00c41579d..ebe70b505150c61acb724ad079eb3b252ef391d4 100644 (file)
@@ -181,12 +181,13 @@ struct hil_proc {
  * This function creates a HIL proc instance for given CPU id and populates
  * it with platform info.
  *
+ * @param pdata  - platform data for remote processor
  * @param cpu_id - cpu id
  *
  * @return - pointer to proc instance
  *
  */
-struct hil_proc *hil_create_proc(int cpu_id);
+struct hil_proc *hil_create_proc(void *pdata, int cpu_id);
 
 /**
  * hil_delete_proc
index 3fbd0e08a7903f4b2abe35bf69503cec5e4dab6d..3c29fdc97183a59d137572479983b5d6825725ce 100644 (file)
@@ -386,6 +386,7 @@ struct rsc_table_info {
  *
  * @param rsc_info          - pointer to resource table info control
  *                            block
+ * @param pdata             - platform data for remote processor
  * @param channel_created   - callback function for channel creation
  * @param channel_destroyed - callback function for channel deletion
  * @param default_cb        - default callback for channel I/O
@@ -395,6 +396,7 @@ struct rsc_table_info {
  *
  */
 int remoteproc_resource_init(struct rsc_table_info *rsc_info,
+                            void *pdata,
                             rpmsg_chnl_cb_t channel_created,
                             rpmsg_chnl_cb_t channel_destroyed,
                             rpmsg_rx_cb_t default_cb,
@@ -420,6 +422,7 @@ int remoteproc_resource_deinit(struct remote_proc *rproc);
  * remoteproc master applications are allowed to call this function.
  *
  * @param fw_name           - name of firmware
+ * @param pdata             - platform data for remote processor
  * @param channel_created   - callback function for channel creation
  * @param channel_destroyed - callback function for channel deletion
  * @param default_cb        - default callback for channel I/O
@@ -428,7 +431,7 @@ int remoteproc_resource_deinit(struct remote_proc *rproc);
  * @param returns - status of function execution
  *
  */
-int remoteproc_init(char *fw_name,
+int remoteproc_init(char *fw_name, void *pdata,
                    rpmsg_chnl_cb_t channel_created,
                    rpmsg_chnl_cb_t channel_destroyed,
                    rpmsg_rx_cb_t default_cb,
index 1230f6b35b4be5a2daed7a7fe26b8072bdd366d5..b126ffc2a256f4882ec48588589a98a3216b9893 100644 (file)
@@ -323,6 +323,7 @@ static inline int rpmsg_trysend_offchannel(struct rpmsg_channel *rpdev,
  * device id (cpu id).The successful return from this function leaves
  * fully enabled IPC link.
  *
+ * @param pdata             - platform data for remote processor
  * @param dev_id            - rpmsg remote device for which driver is to
  *                            be initialized
  * @param rdev              - pointer to newly created remote device
@@ -334,7 +335,7 @@ static inline int rpmsg_trysend_offchannel(struct rpmsg_channel *rpdev,
  *
  */
 
-int rpmsg_init(int dev_id, struct remote_device **rdev,
+int rpmsg_init(void *pdata, int dev_id, struct remote_device **rdev,
               rpmsg_chnl_cb_t channel_created,
               rpmsg_chnl_cb_t channel_destroyed,
               rpmsg_rx_cb_t default_cb, int role);
index f2e814a35199ac49ef60a456f60e83ead62406cb..790df874749975aea19eded7ac0eed948ffd0c5a 100644 (file)
@@ -163,7 +163,7 @@ void rpmsg_ns_callback(struct rpmsg_channel *server_chnl,
                       void *data, int len, void *priv, unsigned long src);
 
 /* Remote device functions */
-int rpmsg_rdev_init(struct remote_device **rdev, int dev_id, int role,
+int rpmsg_rdev_init(void *pdata, struct remote_device **rdev, int dev_id, int role,
                    rpmsg_chnl_cb_t channel_created,
                    rpmsg_chnl_cb_t channel_destroyed,
                    rpmsg_rx_cb_t default_cb);
index 32750e1581efece442facd082a7ae6d6c7fc91f9..792c10a78a835aae28935851e2f0ad998fb4d706 100644 (file)
@@ -44,6 +44,7 @@
  *
  * @param rsc_info          - pointer to resource table info control
  *                                                       block
+ * @param pdata             - platform data for remote processor
  * @param channel_created   - callback function for channel creation
  * @param channel_destroyed - callback function for channel deletion
  * @param default_cb        - default callback for channel I/O
@@ -53,6 +54,7 @@
  *
  */
 int remoteproc_resource_init(struct rsc_table_info *rsc_info,
+                            void *pdata,
                             rpmsg_chnl_cb_t channel_created,
                             rpmsg_chnl_cb_t channel_destroyed,
                             rpmsg_rx_cb_t default_cb,
@@ -71,7 +73,7 @@ int remoteproc_resource_init(struct rsc_table_info *rsc_info,
                memset(rproc, 0x00, sizeof(struct remote_proc));
                /* There can be only one master for remote configuration so use the
                 * rsvd cpu id for creating hil proc */
-               rproc->proc = hil_create_proc(HIL_RSVD_CPU_ID);
+               rproc->proc = hil_create_proc(pdata, HIL_RSVD_CPU_ID);
                if (rproc->proc) {
                        /* Parse resource table */
                        status =
@@ -81,7 +83,7 @@ int remoteproc_resource_init(struct rsc_table_info *rsc_info,
                                /* Initialize RPMSG "messaging" component */
                                *rproc_handle = rproc;
                                status =
-                                   rpmsg_init(rproc->proc->cpu_id,
+                                   rpmsg_init(NULL, rproc->proc->cpu_id,
                                               &rproc->rdev, channel_created,
                                               channel_destroyed, default_cb,
                                               RPMSG_MASTER);
@@ -163,6 +165,7 @@ int remoteproc_resource_deinit(struct remote_proc *rproc)
  * remoteproc master applications are allowed to call this function.
  *
  * @param fw_name           - name of frimware
+ * @param pdata             - platform data for remote processor
  * @param channel_created   - callback function for channel creation
  * @param channel_destroyed - callback function for channel deletion
  * @param default_cb        - default callback for channel I/O
@@ -171,7 +174,8 @@ int remoteproc_resource_deinit(struct remote_proc *rproc)
  * @param returns - status of function execution
  *
  */
-int remoteproc_init(char *fw_name, rpmsg_chnl_cb_t channel_created,
+int remoteproc_init(char *fw_name, void *pdata,
+                   rpmsg_chnl_cb_t channel_created,
                    rpmsg_chnl_cb_t channel_destroyed, rpmsg_rx_cb_t default_cb,
                    struct remote_proc **rproc_handle)
 {
@@ -192,7 +196,7 @@ int remoteproc_init(char *fw_name, rpmsg_chnl_cb_t channel_created,
                cpu_id = hil_get_cpuforfw(fw_name);
                if (cpu_id >= 0) {
                        /* Create proc instance */
-                       rproc->proc = hil_create_proc(cpu_id);
+                       rproc->proc = hil_create_proc(pdata, cpu_id);
                        if (rproc->proc) {
                                /* Retrieve firmware attributes */
                                status =
@@ -327,14 +331,14 @@ int remoteproc_boot(struct remote_proc *rproc)
                                   configuration only. */
 #if defined (OPENAMP_REMOTE_LINUX_ENABLE)
                                status =
-                                   rpmsg_init(rproc->proc->cpu_id,
+                                   rpmsg_init(NULL, rproc->proc->cpu_id,
                                               &rproc->rdev,
                                               rproc->channel_created,
                                               rproc->channel_destroyed,
                                               rproc->default_cb, RPMSG_MASTER);
 #else
                                status =
-                                   rpmsg_init(rproc->proc->cpu_id,
+                                   rpmsg_init(NULL, rproc->proc->cpu_id,
                                               &rproc->rdev,
                                               rproc->channel_created,
                                               rproc->channel_destroyed,
index 3dcb55069f66bbaed608065a0454f160f0199940..76f18ed77616725ece2ce4d671b555bf6ba835ff 100644 (file)
@@ -78,6 +78,7 @@ virtio_dispatch rpmsg_rdev_config_ops = {
  * This function creates and initializes the remote device. The remote device
  * encapsulates virtio device.
  *
+ * @param pdata             - platform data for remote processor
  * @param rdev              - pointer to newly created remote device
  * @param dev-id            - ID of device to create , remote cpu id
  * @param role              - role of the other device, Master or Remote
@@ -88,7 +89,7 @@ virtio_dispatch rpmsg_rdev_config_ops = {
  * @return - status of function execution
  *
  */
-int rpmsg_rdev_init(struct remote_device **rdev, int dev_id, int role,
+int rpmsg_rdev_init(void *pdata, struct remote_device **rdev, int dev_id, int role,
                    rpmsg_chnl_cb_t channel_created,
                    rpmsg_chnl_cb_t channel_destroyed, rpmsg_rx_cb_t default_cb)
 {
@@ -100,7 +101,7 @@ int rpmsg_rdev_init(struct remote_device **rdev, int dev_id, int role,
        int status;
 
        /* Initialize HIL data structures for given device */
-       proc = hil_create_proc(dev_id);
+       proc = hil_create_proc(pdata, dev_id);
 
        if (!proc) {
                return RPMSG_ERR_DEV_ID;
index 40f47d2bce237e9b1c43b755616c6d23a568fc36..a9f268b949b274dddb7ede4eda80099207db3476 100644 (file)
@@ -65,6 +65,7 @@
  * given device ID(cpu id). The successful return from this function leaves
  * fully enabled IPC link.
  *
+ * @param pdata             - platform data for remote processor
  * @param dev_id            - remote device for which driver is to
  *                            be initialized
  * @param rdev              - pointer to newly created remote device
@@ -77,7 +78,7 @@
  *
  */
 
-int rpmsg_init(int dev_id, struct remote_device **rdev,
+int rpmsg_init(void *pdata, int dev_id, struct remote_device **rdev,
               rpmsg_chnl_cb_t channel_created,
               rpmsg_chnl_cb_t channel_destroyed,
               rpmsg_rx_cb_t default_cb, int role)
@@ -85,7 +86,7 @@ int rpmsg_init(int dev_id, struct remote_device **rdev,
        int status;
 
        /* Initialize the remote device for given cpu id */
-       status = rpmsg_rdev_init(rdev, dev_id, role, channel_created,
+       status = rpmsg_rdev_init(pdata, rdev, dev_id, role, channel_created,
                                 channel_destroyed, default_cb);
        if (status == RPMSG_SUCCESS) {
                /* Kick off IPC with the remote device */