From: Igal Liberman
Add Frame Manager Multi-User RAM support.
Signed-off-by: Igal Liberman
---
drivers/soc/fsl/fman/Kconfig|1 +
drivers/soc/fsl/fman/Makefile |5 +-
drivers/soc/fsl/fman/fm_muram.c | 174 +++
drivers/soc/fsl/fman/inc/fm_muram_ext.h | 98 +
4 files changed, 276 insertions(+), 2 deletions(-)
create mode 100644 drivers/soc/fsl/fman/fm_muram.c
create mode 100644 drivers/soc/fsl/fman/inc/fm_muram_ext.h
diff --git a/drivers/soc/fsl/fman/Kconfig b/drivers/soc/fsl/fman/Kconfig
index 4a9f672..92593b7 100644
--- a/drivers/soc/fsl/fman/Kconfig
+++ b/drivers/soc/fsl/fman/Kconfig
@@ -1,6 +1,7 @@
menuconfig FSL_FMAN
bool "Freescale DPAA Frame Manager"
depends on FSL_SOC || COMPILE_TEST
+ select PPC_LIB_RHEAP
default n
help
Freescale Data-Path Acceleration Architecture Frame Manager
diff --git a/drivers/soc/fsl/fman/Makefile b/drivers/soc/fsl/fman/Makefile
index b5ea613..89a84a7 100644
--- a/drivers/soc/fsl/fman/Makefile
+++ b/drivers/soc/fsl/fman/Makefile
@@ -1,8 +1,9 @@
-subdir-ccflags-$(CONFIG_FSL_FMAN) += -I$(srctree)/drivers/soc/fsl/fman/flib
+subdir-ccflags-$(CONFIG_FSL_FMAN) += -I$(srctree)/drivers/soc/fsl/fman/flib \
+-I$(srctree)/drivers/soc/fsl/fman/inc
obj-$(CONFIG_FSL_FMAN) += fsl_fman.o
-fsl_fman-objs := fman.o
+fsl_fman-objs := fman.o fm_muram.o
obj-$(CONFIG_FSL_FMAN_PORT)+= port/
obj-$(CONFIG_FSL_FMAN_MAC) += mac/
diff --git a/drivers/soc/fsl/fman/fm_muram.c b/drivers/soc/fsl/fman/fm_muram.c
new file mode 100644
index 000..2a67a2e
--- /dev/null
+++ b/drivers/soc/fsl/fman/fm_muram.c
@@ -0,0 +1,174 @@
+/*
+ * Copyright 2008-2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* FM MURAM ... */
+#include "fm_muram_ext.h"
+
+#include
+#include
+#include
+
+struct muram_info {
+ rh_block_t fm_boot_muram_rh_block[16];
+ rh_info_t *fm_muram_info;
+ void __iomem *fm_muram_vbase;
+ /* Spinlock for MURAM accesses */
+ spinlock_t fm_muram_lock;
+ uint64_tsize;
+};
+
+static void __iomem *fm_muram_addr(struct muram_info *p_muram,
+ unsigned long offset)
+{
+ return p_muram->fm_muram_vbase + offset;
+}
+
+static unsigned long fm_muram_offset(struct muram_info *p_muram,
+void __iomem *addr)
+{
+ return addr - p_muram->fm_muram_vbase;
+}
+
+void fm_muram_clear(struct muram_info *p_muram)
+{
+ memset_io(p_muram->fm_muram_vbase, 0, p_muram->size);
+}
+
+struct muram_info *fm_muram_init(phys_addr_t base_address, uint64_t size)
+{
+ int ret;
+ struct muram_info *p_muram;
+
+ p_muram = kzalloc(sizeof(*p_muram), GFP_KERNEL);
+ if (!p_muram)
+ return NULL;
+ /* Create remote heap */
+ p_muram->fm_muram_info = rh_create(sizeof(unsigned int));
+
+ /* Spinlock for MURAM accesses */
+ spin_lock_init(&p_muram->fm_muram_lock);
+
+ /* Initialize the info header */
+ rh_init(p_muram->fm_muram_info, 1,
+ sizeof(p_muram->fm_boot