Remove remoteproc_plat from ZynqMP R5 rproc driver
authorWendy Liang <jliang@xilinx.com>
Thu, 22 Sep 2016 06:25:41 +0000 (23:25 -0700)
committerWendy Liang <jliang@xilinx.com>
Thu, 13 Oct 2016 05:01:50 +0000 (22:01 -0700)
As remoteproc_plat has been removed, update the driver not
to use that driver.

Signed-off-by: Wendy Liang <jliang@xilinx.com>
lib/remoteproc/drivers/zynqmp_remoteproc_a53.c

index 061baab398cba8e8a9f03cf5be04c2c59908565f..92a7fa1b7bebb7fc6069767eb8ff06c10ab74c64 100644 (file)
@@ -49,7 +49,6 @@
 #include "metal/irq.h"
 #include "metal/alloc.h"
 #include "openamp/hil.h"
 #include "metal/irq.h"
 #include "metal/alloc.h"
 #include "openamp/hil.h"
-#include "openamp/remoteproc_plat.h"
 #include "openamp/virtqueue.h"
 
 /* IPI REGs OFFSET */
 #include "openamp/virtqueue.h"
 
 /* IPI REGs OFFSET */
 
 /* -- FIX ME: ipi info is to be defined -- */
 struct ipi_info {
 
 /* -- FIX ME: ipi info is to be defined -- */
 struct ipi_info {
+       const char *name;
+       const char *bus_name;
+       struct metal_device *dev;
+       struct metal_io_region *io;
+       metal_phys_addr_t paddr;
        uint32_t ipi_chn_mask;
        int need_reg;
        atomic_int sync;
        uint32_t ipi_chn_mask;
        int need_reg;
        atomic_int sync;
@@ -71,11 +75,11 @@ struct ipi_info {
 
 /*--------------------------- Declare Functions ------------------------ */
 static int _enable_interrupt(struct proc_vring *vring_hw);
 
 /*--------------------------- Declare Functions ------------------------ */
 static int _enable_interrupt(struct proc_vring *vring_hw);
-static void _notify(int cpu_id, struct proc_intr *intr_info);
-static int _boot_cpu(int cpu_id, unsigned int load_addr);
-static void _shutdown_cpu(int cpu_id);
+static void _notify(struct hil_proc *proc, struct proc_intr *intr_info);
+static int _boot_cpu(struct hil_proc *proc, unsigned int load_addr);
+static void _shutdown_cpu(struct hil_proc *proc);
 static int _poll(struct hil_proc *proc, int nonblock);
 static int _poll(struct hil_proc *proc, int nonblock);
-static struct hil_proc *_initialize(void *pdata, int cpu_id);
+static int _initialize(struct hil_proc *proc);
 static void _release(struct hil_proc *proc);
 
 static int _ipi_handler(int vect_id, void *data);
 static void _release(struct hil_proc *proc);
 
 static int _ipi_handler(int vect_id, void *data);
@@ -97,7 +101,7 @@ int _ipi_handler(int vect_id, void *data)
        struct proc_vring *vring_hw = (struct proc_vring *)(data);
        struct ipi_info *ipi =
                (struct ipi_info *)(vring_hw->intr_info.data);
        struct proc_vring *vring_hw = (struct proc_vring *)(data);
        struct ipi_info *ipi =
                (struct ipi_info *)(vring_hw->intr_info.data);
-       struct metal_io_region *io = vring_hw->intr_info.io;
+       struct metal_io_region *io = ipi->io;
        unsigned int ipi_intr_status =
            (unsigned int)metal_io_read32(io, IPI_ISR_OFFSET);
        if (ipi_intr_status & ipi->ipi_chn_mask) {
        unsigned int ipi_intr_status =
            (unsigned int)metal_io_read32(io, IPI_ISR_OFFSET);
        if (ipi_intr_status & ipi->ipi_chn_mask) {
@@ -113,7 +117,7 @@ static int _enable_interrupt(struct proc_vring *vring_hw)
 {
        struct ipi_info *ipi =
            (struct ipi_info *)(vring_hw->intr_info.data);
 {
        struct ipi_info *ipi =
            (struct ipi_info *)(vring_hw->intr_info.data);
-       struct metal_io_region *io = vring_hw->intr_info.io;
+       struct metal_io_region *io = ipi->io;
 
        if (!ipi->need_reg) {
                return 0;
 
        if (!ipi->need_reg) {
                return 0;
@@ -128,28 +132,28 @@ static int _enable_interrupt(struct proc_vring *vring_hw)
        return 0;
 }
 
        return 0;
 }
 
-static void _notify(int cpu_id, struct proc_intr *intr_info)
+static void _notify(struct hil_proc *proc, struct proc_intr *intr_info)
 {
 
 {
 
-       (void)cpu_id;
+       (void)proc;
        struct ipi_info *ipi = (struct ipi_info *)(intr_info->data);
        if (ipi == NULL)
                return;
 
        /* Trigger IPI */
        struct ipi_info *ipi = (struct ipi_info *)(intr_info->data);
        if (ipi == NULL)
                return;
 
        /* Trigger IPI */
-       metal_io_write32(intr_info->io, IPI_TRIG_OFFSET, ipi->ipi_chn_mask);
+       metal_io_write32(ipi->io, IPI_TRIG_OFFSET, ipi->ipi_chn_mask);
 }
 
 }
 
-static int _boot_cpu(int cpu_id, unsigned int load_addr)
+static int _boot_cpu(struct hil_proc *proc, unsigned int load_addr)
 {
 {
-       (void)cpu_id;
+       (void)proc;
        (void)load_addr;
        return -1;
 }
 
        (void)load_addr;
        return -1;
 }
 
-static void _shutdown_cpu(int cpu_id)
+static void _shutdown_cpu(struct hil_proc *proc)
 {
 {
-       (void)cpu_id;
+       (void)proc;
        return;
 }
 
        return;
 }
 
@@ -177,57 +181,82 @@ static int _poll(struct hil_proc *proc, int nonblock)
        }
 }
 
        }
 }
 
-static struct hil_proc * _initialize(void *pdata, int cpu_id)
+static int _initialize(struct hil_proc *proc)
 {
 {
-       (void) cpu_id;
-
-       struct hil_proc *proc;
        int ret;
        int ret;
-       struct metal_io_region *io;
        struct proc_intr *intr_info;
        struct ipi_info *ipi;
        unsigned int ipi_intr_status;
        struct proc_intr *intr_info;
        struct ipi_info *ipi;
        unsigned int ipi_intr_status;
+       int i;
 
 
-       /* Allocate memory for proc instance */
-       proc = metal_allocate_memory(sizeof(struct hil_proc));
-       if (!proc) {
-               return NULL;
-       }
-       memset(proc, 0, sizeof(struct hil_proc));
-
-       ret = rproc_init_plat_data(pdata, proc);
-       if (ret)
-               goto error;
-       intr_info = &(proc->vdev.vring_info[1].intr_info);
-       io = intr_info->io;
-       ipi = (struct ipi_info *)(intr_info->data);
-       ipi_intr_status =
-           (unsigned int)metal_io_read32(io, IPI_ISR_OFFSET);
-       if (ipi_intr_status & ipi->ipi_chn_mask) {
-               metal_io_write32(io, IPI_ISR_OFFSET, ipi->ipi_chn_mask);
+       if (!proc)
+               return -1;
+
+       for (i = 0; i < HIL_MAX_NUM_VRINGS; i++) {
+               intr_info = &(proc->vdev.vring_info[i].intr_info);
+               ipi = intr_info->data;
+
+               if (ipi && ipi->name && ipi->bus_name) {
+                       ret = metal_device_open(ipi->bus_name, ipi->name,
+                                                    &ipi->dev);
+                       if (ret)
+                               return -ENODEV;
+                       ipi->io = metal_device_io_region(ipi->dev, 0);
+               } else if (ipi->paddr) {
+                       ipi->io = metal_allocate_memory(
+                               sizeof(struct metal_io_region));
+                       if (!ipi->io)
+                               goto error;
+                       metal_io_init(ipi->io, (void *)ipi->paddr,
+                               &ipi->paddr, 0x1000,
+                               (unsigned)(-1),
+                               METAL_UNCACHED | METAL_IO_MAPPED,
+                               NULL);
+               }
+
+               if (ipi->io) {
+                       ipi_intr_status = (unsigned int)metal_io_read32(
+                               ipi->io, IPI_ISR_OFFSET);
+                       if (ipi_intr_status & ipi->ipi_chn_mask)
+                               metal_io_write32(ipi->io, IPI_ISR_OFFSET,
+                                       ipi->ipi_chn_mask);
+                       metal_io_write32(ipi->io, IPI_IDR_OFFSET,
+                               ipi->ipi_chn_mask);
+                       atomic_store(&ipi->sync, 1);
+               }
        }
        }
-       metal_io_write32(io, IPI_IDR_OFFSET, ipi->ipi_chn_mask);
-       atomic_store(&ipi->sync, 1);
-       return proc;
+       return 0;
+
 error:
 error:
-       if (proc) {
-               rproc_close_plat(proc);
-               metal_free_memory(proc);
-       }
-       return NULL;
+       _release(proc);
+       return -1;
 }
 
 static void _release(struct hil_proc *proc)
 {
 }
 
 static void _release(struct hil_proc *proc)
 {
-       if (proc) {
-               struct proc_intr *intr_info =
-                       &(proc->vdev.vring_info[1].intr_info);
-               struct metal_io_region *io = intr_info->io;
-               struct ipi_info *ipi = (struct ipi_info *)(intr_info->data);
-               metal_io_write32(io, IPI_IDR_OFFSET, ipi->ipi_chn_mask);
-
-               rproc_close_plat(proc);
-               metal_free_memory(proc);
+       int i;
+       struct proc_intr *intr_info;
+       struct ipi_info *ipi;
+
+       if (!proc)
+               return;
+       for (i = 0; i < HIL_MAX_NUM_VRINGS; i++) {
+               intr_info = &(proc->vdev.vring_info[1].intr_info);
+               ipi = (struct ipi_info *)(intr_info->data);
+               if (ipi) {
+                       if (ipi->io) {
+                               metal_io_write32(ipi->io, IPI_IDR_OFFSET,
+                                       ipi->ipi_chn_mask);
+                               if (ipi->dev) {
+                                       metal_device_close(ipi->dev);
+                                       ipi->dev = NULL;
+                               } else {
+                                       metal_free_memory(ipi->io);
+                               }
+                               ipi->io = NULL;
+                       }
+               }
+
        }
 }
 
        }
 }