@@ -27,6 +27,20 @@
#include <linux/slab.h>
#include <linux/mtd/mtd.h>
+/*
+ * It is of the form:
+ * wc=Y/N for module case
+ * phram.wc=Y/N for built-in case
+ */
+static bool wc;
+module_param(wc, bool, 0);
+MODULE_PARM_DESC(wc, "How we remap reserved memory to a phram device\n"
+ "\tSay N(default) to use ioremap(): \"wc=N\"\n"
+ "\tSay Y to use ioremap_wc(): \"wc=Y\"\n"
+ "\tOn ARM64, writing to phram device using ioremap()\n"
+ "\tat addr not aligned to 8-bytes will cause oops,\n"
+ "\tioremap_wc() could fix it.");
+
struct phram_mtd_list {
struct mtd_info mtd;
struct list_head list;
@@ -98,7 +112,11 @@ static int register_device(char *name, phys_addr_t start, size_t len)
goto out0;
ret = -EIO;
- new->mtd.priv = ioremap(start, len);
+ if (wc)
+ new->mtd.priv = ioremap_wc(start, len);
+ else
+ new->mtd.priv = ioremap(start, len);
+
if (!new->mtd.priv) {
pr_err("ioremap failed\n");
goto out1;