]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
powerpc/powernv: Move SCOM access code into powernv platform
authorAndrew Donnellan <ajd@linux.ibm.com>
Thu, 9 May 2019 05:11:15 +0000 (15:11 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 5 Aug 2019 08:53:03 +0000 (18:53 +1000)
The powernv platform is the only one that directly accesses SCOMs.
Move the support code to platforms/powernv, and get rid of the
PPC_SCOM Kconfig option, as SCOM support is always selected when
compiling for powernv.

This also means that the Kconfig item for CONFIG_SCOM_DEBUGFS will
show up in menuconfig in the platform menu, rather than at the root,
which is a much better location.

Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20190509051119.7694-1-ajd@linux.ibm.com
arch/powerpc/include/asm/scom.h [deleted file]
arch/powerpc/platforms/powernv/Kconfig
arch/powerpc/platforms/powernv/Makefile
arch/powerpc/platforms/powernv/opal-xscom.c
arch/powerpc/platforms/powernv/scom.c [new file with mode: 0644]
arch/powerpc/platforms/powernv/scom.h [new file with mode: 0644]
arch/powerpc/sysdev/Kconfig
arch/powerpc/sysdev/Makefile
arch/powerpc/sysdev/scom.c [deleted file]

diff --git a/arch/powerpc/include/asm/scom.h b/arch/powerpc/include/asm/scom.h
deleted file mode 100644 (file)
index 08c4439..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright 2010 Benjamin Herrenschmidt, IBM Corp
- *                <benh@kernel.crashing.org>
- *     and        David Gibson, IBM Corporation.
- */
-
-#ifndef _ASM_POWERPC_SCOM_H
-#define _ASM_POWERPC_SCOM_H
-
-#ifdef __KERNEL__
-#ifndef __ASSEMBLY__
-#ifdef CONFIG_PPC_SCOM
-
-/*
- * The SCOM bus is a sideband bus used for accessing various internal
- * registers of the processor or the chipset. The implementation details
- * differ between processors and platforms, and the access method as
- * well.
- *
- * This API allows to "map" ranges of SCOM register numbers associated
- * with a given SCOM controller. The later must be represented by a
- * device node, though some implementations might support NULL if there
- * is no possible ambiguity
- *
- * Then, scom_read/scom_write can be used to accesses registers inside
- * that range. The argument passed is a register number relative to
- * the beginning of the range mapped.
- */
-
-typedef void *scom_map_t;
-
-/* Value for an invalid SCOM map */
-#define SCOM_MAP_INVALID       (NULL)
-
-/* The scom_controller data structure is what the platform passes
- * to the core code in scom_init, it provides the actual implementation
- * of all the SCOM functions
- */
-struct scom_controller {
-       scom_map_t (*map)(struct device_node *ctrl_dev, u64 reg, u64 count);
-       void (*unmap)(scom_map_t map);
-
-       int (*read)(scom_map_t map, u64 reg, u64 *value);
-       int (*write)(scom_map_t map, u64 reg, u64 value);
-};
-
-extern const struct scom_controller *scom_controller;
-
-/**
- * scom_init - Initialize the SCOM backend, called by the platform
- * @controller: The platform SCOM controller
- */
-static inline void scom_init(const struct scom_controller *controller)
-{
-       scom_controller = controller;
-}
-
-/**
- * scom_map_ok - Test is a SCOM mapping is successful
- * @map: The result of scom_map to test
- */
-static inline int scom_map_ok(scom_map_t map)
-{
-       return map != SCOM_MAP_INVALID;
-}
-
-/**
- * scom_map - Map a block of SCOM registers
- * @ctrl_dev: Device node of the SCOM controller
- *            some implementations allow NULL here
- * @reg: first SCOM register to map
- * @count: Number of SCOM registers to map
- */
-
-static inline scom_map_t scom_map(struct device_node *ctrl_dev,
-                                 u64 reg, u64 count)
-{
-       return scom_controller->map(ctrl_dev, reg, count);
-}
-
-/**
- * scom_find_parent - Find the SCOM controller for a device
- * @dev: OF node of the device
- *
- * This is not meant for general usage, but in combination with
- * scom_map() allows to map registers not represented by the
- * device own scom-reg property. Useful for applying HW workarounds
- * on things not properly represented in the device-tree for example.
- */
-struct device_node *scom_find_parent(struct device_node *dev);
-
-
-/**
- * scom_map_device - Map a device's block of SCOM registers
- * @dev: OF node of the device
- * @index: Register bank index (index in "scom-reg" property)
- *
- * This function will use the device-tree binding for SCOM which
- * is to follow "scom-parent" properties until it finds a node with
- * a "scom-controller" property to find the controller. It will then
- * use the "scom-reg" property which is made of reg/count pairs,
- * each of them having a size defined by the controller's #scom-cells
- * property
- */
-extern scom_map_t scom_map_device(struct device_node *dev, int index);
-
-
-/**
- * scom_unmap - Unmap a block of SCOM registers
- * @map: Result of scom_map is to be unmapped
- */
-static inline void scom_unmap(scom_map_t map)
-{
-       if (scom_map_ok(map))
-               scom_controller->unmap(map);
-}
-
-/**
- * scom_read - Read a SCOM register
- * @map: Result of scom_map
- * @reg: Register index within that map
- * @value: Updated with the value read
- *
- * Returns 0 (success) or a negative error code
- */
-static inline int scom_read(scom_map_t map, u64 reg, u64 *value)
-{
-       int rc;
-
-       rc = scom_controller->read(map, reg, value);
-       if (rc)
-               *value = 0xfffffffffffffffful;
-       return rc;
-}
-
-/**
- * scom_write - Write to a SCOM register
- * @map: Result of scom_map
- * @reg: Register index within that map
- * @value: Value to write
- *
- * Returns 0 (success) or a negative error code
- */
-static inline int scom_write(scom_map_t map, u64 reg, u64 value)
-{
-       return scom_controller->write(map, reg, value);
-}
-
-
-#endif /* CONFIG_PPC_SCOM */
-#endif /* __ASSEMBLY__ */
-#endif /* __KERNEL__ */
-#endif /* _ASM_POWERPC_SCOM_H */
index 850eee860cf21c0eacfb39aeb358bbc4b1438b14..938803eab0ad432a9818fdd06bad73dfd272050f 100644 (file)
@@ -12,7 +12,6 @@ config PPC_POWERNV
        select EPAPR_BOOT
        select PPC_INDIRECT_PIO
        select PPC_UDBG_16550
-       select PPC_SCOM
        select ARCH_RANDOM
        select CPU_FREQ
        select PPC_DOORBELL
@@ -47,3 +46,7 @@ config PPC_VAS
          VAS adapters are found in POWER9 based systems.
 
          If unsure, say N.
+
+config SCOM_DEBUGFS
+       bool "Expose SCOM controllers via debugfs"
+       depends on DEBUG_FS
index da2e99efbd04e623f6761b49c16bcd9da06a88d8..4b1644150135322b51db96ff910df2c95b697845 100644 (file)
@@ -4,12 +4,12 @@ obj-y                 += idle.o opal-rtc.o opal-nvram.o opal-lpc.o opal-flash.o
 obj-y                  += rng.o opal-elog.o opal-dump.o opal-sysparam.o opal-sensor.o
 obj-y                  += opal-msglog.o opal-hmi.o opal-power.o opal-irqchip.o
 obj-y                  += opal-kmsg.o opal-powercap.o opal-psr.o opal-sensor-groups.o
+obj-y                  += opal-xscom.o scom.o
 
 obj-$(CONFIG_SMP)      += smp.o subcore.o subcore-asm.o
 obj-$(CONFIG_PCI)      += pci.o pci-ioda.o npu-dma.o pci-ioda-tce.o
 obj-$(CONFIG_CXL_BASE) += pci-cxl.o
 obj-$(CONFIG_EEH)      += eeh-powernv.o
-obj-$(CONFIG_PPC_SCOM) += opal-xscom.o
 obj-$(CONFIG_MEMORY_FAILURE)   += opal-memory-errors.o
 obj-$(CONFIG_OPAL_PRD) += opal-prd.o
 obj-$(CONFIG_PERF_EVENTS) += opal-imc.o
index 66430eebe869a364a2e5703bb8b2ce5d049d2fe6..3f48ee69928ce0199edc25c194d5cb5665ecb5fc 100644 (file)
@@ -14,7 +14,8 @@
 #include <asm/machdep.h>
 #include <asm/firmware.h>
 #include <asm/opal.h>
-#include <asm/scom.h>
+
+#include "scom.h"
 
 /*
  * We could probably fit that inside the scom_map_t
diff --git a/arch/powerpc/platforms/powernv/scom.c b/arch/powerpc/platforms/powernv/scom.c
new file mode 100644 (file)
index 0000000..74664e9
--- /dev/null
@@ -0,0 +1,224 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright 2010 Benjamin Herrenschmidt, IBM Corp
+ *                <benh@kernel.crashing.org>
+ *     and        David Gibson, IBM Corporation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/export.h>
+#include <asm/debugfs.h>
+#include <asm/prom.h>
+#include <linux/uaccess.h>
+
+#include "scom.h"
+
+const struct scom_controller *scom_controller;
+EXPORT_SYMBOL_GPL(scom_controller);
+
+struct device_node *scom_find_parent(struct device_node *node)
+{
+       struct device_node *par, *tmp;
+       const u32 *p;
+
+       for (par = of_node_get(node); par;) {
+               if (of_get_property(par, "scom-controller", NULL))
+                       break;
+               p = of_get_property(par, "scom-parent", NULL);
+               tmp = par;
+               if (p == NULL)
+                       par = of_get_parent(par);
+               else
+                       par = of_find_node_by_phandle(*p);
+               of_node_put(tmp);
+       }
+       return par;
+}
+EXPORT_SYMBOL_GPL(scom_find_parent);
+
+scom_map_t scom_map_device(struct device_node *dev, int index)
+{
+       struct device_node *parent;
+       unsigned int cells, size;
+       const __be32 *prop, *sprop;
+       u64 reg, cnt;
+       scom_map_t ret;
+
+       parent = scom_find_parent(dev);
+
+       if (parent == NULL)
+               return NULL;
+
+       /*
+        * We support "scom-reg" properties for adding scom registers
+        * to a random device-tree node with an explicit scom-parent
+        *
+        * We also support the simple "reg" property if the device is
+        * a direct child of a scom controller.
+        *
+        * In case both exist, "scom-reg" takes precedence.
+        */
+       prop = of_get_property(dev, "scom-reg", &size);
+       sprop = of_get_property(parent, "#scom-cells", NULL);
+       if (!prop && parent == dev->parent) {
+               prop = of_get_property(dev, "reg", &size);
+               sprop = of_get_property(parent, "#address-cells", NULL);
+       }
+       if (!prop)
+               return NULL;
+       cells = sprop ? be32_to_cpup(sprop) : 1;
+       size >>= 2;
+
+       if (index >= (size / (2*cells)))
+               return NULL;
+
+       reg = of_read_number(&prop[index * cells * 2], cells);
+       cnt = of_read_number(&prop[index * cells * 2 + cells], cells);
+
+       ret = scom_map(parent, reg, cnt);
+       of_node_put(parent);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(scom_map_device);
+
+#ifdef CONFIG_SCOM_DEBUGFS
+struct scom_debug_entry {
+       struct device_node *dn;
+       struct debugfs_blob_wrapper path;
+       char name[16];
+};
+
+static ssize_t scom_debug_read(struct file *filp, char __user *ubuf,
+                              size_t count, loff_t *ppos)
+{
+       struct scom_debug_entry *ent = filp->private_data;
+       u64 __user *ubuf64 = (u64 __user *)ubuf;
+       loff_t off = *ppos;
+       ssize_t done = 0; 
+       u64 reg, reg_cnt, val;
+       scom_map_t map;
+       int rc;
+
+       if (off < 0 || (off & 7) || (count & 7))
+               return -EINVAL;
+       reg = off >> 3;
+       reg_cnt = count >> 3;
+
+       map = scom_map(ent->dn, reg, reg_cnt);
+       if (!scom_map_ok(map))
+               return -ENXIO;
+
+       for (reg = 0; reg < reg_cnt; reg++) {
+               rc = scom_read(map, reg, &val);
+               if (!rc)
+                       rc = put_user(val, ubuf64);
+               if (rc) {
+                       if (!done)
+                               done = rc;
+                       break;
+               }
+               ubuf64++;
+               *ppos += 8;
+               done += 8;
+       }
+       scom_unmap(map);
+       return done;
+}
+
+static ssize_t scom_debug_write(struct file* filp, const char __user *ubuf,
+                               size_t count, loff_t *ppos)
+{
+       struct scom_debug_entry *ent = filp->private_data;
+       u64 __user *ubuf64 = (u64 __user *)ubuf;
+       loff_t off = *ppos;
+       ssize_t done = 0; 
+       u64 reg, reg_cnt, val;
+       scom_map_t map;
+       int rc;
+
+       if (off < 0 || (off & 7) || (count & 7))
+               return -EINVAL;
+       reg = off >> 3;
+       reg_cnt = count >> 3;
+
+       map = scom_map(ent->dn, reg, reg_cnt);
+       if (!scom_map_ok(map))
+               return -ENXIO;
+
+       for (reg = 0; reg < reg_cnt; reg++) {
+               rc = get_user(val, ubuf64);
+               if (!rc)
+                       rc = scom_write(map, reg,  val);
+               if (rc) {
+                       if (!done)
+                               done = rc;
+                       break;
+               }
+               ubuf64++;
+               done += 8;
+       }
+       scom_unmap(map);
+       return done;
+}
+
+static const struct file_operations scom_debug_fops = {
+       .read =         scom_debug_read,
+       .write =        scom_debug_write,
+       .open =         simple_open,
+       .llseek =       default_llseek,
+};
+
+static int scom_debug_init_one(struct dentry *root, struct device_node *dn,
+                              int i)
+{
+       struct scom_debug_entry *ent;
+       struct dentry *dir;
+
+       ent = kzalloc(sizeof(*ent), GFP_KERNEL);
+       if (!ent)
+               return -ENOMEM;
+
+       ent->dn = of_node_get(dn);
+       snprintf(ent->name, 16, "%08x", i);
+       ent->path.data = (void*)kasprintf(GFP_KERNEL, "%pOF", dn);
+       ent->path.size = strlen((char *)ent->path.data);
+
+       dir = debugfs_create_dir(ent->name, root);
+       if (!dir) {
+               of_node_put(dn);
+               kfree(ent->path.data);
+               kfree(ent);
+               return -1;
+       }
+
+       debugfs_create_blob("devspec", 0400, dir, &ent->path);
+       debugfs_create_file("access", 0600, dir, ent, &scom_debug_fops);
+
+       return 0;
+}
+
+static int scom_debug_init(void)
+{
+       struct device_node *dn;
+       struct dentry *root;
+       int i, rc;
+
+       root = debugfs_create_dir("scom", powerpc_debugfs_root);
+       if (!root)
+               return -1;
+
+       i = rc = 0;
+       for_each_node_with_property(dn, "scom-controller") {
+               int id = of_get_ibm_chip_id(dn);
+               if (id == -1)
+                       id = i;
+               rc |= scom_debug_init_one(root, dn, id);
+               i++;
+       }
+
+       return rc;
+}
+device_initcall(scom_debug_init);
+#endif /* CONFIG_SCOM_DEBUGFS */
diff --git a/arch/powerpc/platforms/powernv/scom.h b/arch/powerpc/platforms/powernv/scom.h
new file mode 100644 (file)
index 0000000..b5c33e3
--- /dev/null
@@ -0,0 +1,147 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright 2010 Benjamin Herrenschmidt, IBM Corp
+ *                <benh@kernel.crashing.org>
+ *     and        David Gibson, IBM Corporation.
+ */
+
+#ifndef _SCOM_H
+#define _SCOM_H
+
+/*
+ * The SCOM bus is a sideband bus used for accessing various internal
+ * registers of the processor or the chipset. The implementation details
+ * differ between processors and platforms, and the access method as
+ * well.
+ *
+ * This API allows to "map" ranges of SCOM register numbers associated
+ * with a given SCOM controller. The later must be represented by a
+ * device node, though some implementations might support NULL if there
+ * is no possible ambiguity
+ *
+ * Then, scom_read/scom_write can be used to accesses registers inside
+ * that range. The argument passed is a register number relative to
+ * the beginning of the range mapped.
+ */
+
+typedef void *scom_map_t;
+
+/* Value for an invalid SCOM map */
+#define SCOM_MAP_INVALID       (NULL)
+
+/* The scom_controller data structure is what the platform passes
+ * to the core code in scom_init, it provides the actual implementation
+ * of all the SCOM functions
+ */
+struct scom_controller {
+       scom_map_t (*map)(struct device_node *ctrl_dev, u64 reg, u64 count);
+       void (*unmap)(scom_map_t map);
+
+       int (*read)(scom_map_t map, u64 reg, u64 *value);
+       int (*write)(scom_map_t map, u64 reg, u64 value);
+};
+
+extern const struct scom_controller *scom_controller;
+
+/**
+ * scom_init - Initialize the SCOM backend, called by the platform
+ * @controller: The platform SCOM controller
+ */
+static inline void scom_init(const struct scom_controller *controller)
+{
+       scom_controller = controller;
+}
+
+/**
+ * scom_map_ok - Test is a SCOM mapping is successful
+ * @map: The result of scom_map to test
+ */
+static inline int scom_map_ok(scom_map_t map)
+{
+       return map != SCOM_MAP_INVALID;
+}
+
+/**
+ * scom_map - Map a block of SCOM registers
+ * @ctrl_dev: Device node of the SCOM controller
+ *            some implementations allow NULL here
+ * @reg: first SCOM register to map
+ * @count: Number of SCOM registers to map
+ */
+
+static inline scom_map_t scom_map(struct device_node *ctrl_dev,
+                                 u64 reg, u64 count)
+{
+       return scom_controller->map(ctrl_dev, reg, count);
+}
+
+/**
+ * scom_find_parent - Find the SCOM controller for a device
+ * @dev: OF node of the device
+ *
+ * This is not meant for general usage, but in combination with
+ * scom_map() allows to map registers not represented by the
+ * device own scom-reg property. Useful for applying HW workarounds
+ * on things not properly represented in the device-tree for example.
+ */
+struct device_node *scom_find_parent(struct device_node *dev);
+
+
+/**
+ * scom_map_device - Map a device's block of SCOM registers
+ * @dev: OF node of the device
+ * @index: Register bank index (index in "scom-reg" property)
+ *
+ * This function will use the device-tree binding for SCOM which
+ * is to follow "scom-parent" properties until it finds a node with
+ * a "scom-controller" property to find the controller. It will then
+ * use the "scom-reg" property which is made of reg/count pairs,
+ * each of them having a size defined by the controller's #scom-cells
+ * property
+ */
+extern scom_map_t scom_map_device(struct device_node *dev, int index);
+
+
+/**
+ * scom_unmap - Unmap a block of SCOM registers
+ * @map: Result of scom_map is to be unmapped
+ */
+static inline void scom_unmap(scom_map_t map)
+{
+       if (scom_map_ok(map))
+               scom_controller->unmap(map);
+}
+
+/**
+ * scom_read - Read a SCOM register
+ * @map: Result of scom_map
+ * @reg: Register index within that map
+ * @value: Updated with the value read
+ *
+ * Returns 0 (success) or a negative error code
+ */
+static inline int scom_read(scom_map_t map, u64 reg, u64 *value)
+{
+       int rc;
+
+       rc = scom_controller->read(map, reg, value);
+       if (rc)
+               *value = 0xfffffffffffffffful;
+       return rc;
+}
+
+/**
+ * scom_write - Write to a SCOM register
+ * @map: Result of scom_map
+ * @reg: Register index within that map
+ * @value: Value to write
+ *
+ * Returns 0 (success) or a negative error code
+ */
+static inline int scom_write(scom_map_t map, u64 reg, u64 value)
+{
+       return scom_controller->write(map, reg, value);
+}
+
+
+#endif /* _SCOM_H */
index d23288c4abf668cb926346820b39b9045ede1322..9ebcc13375603c2e76844f8ce63162af0dd7726b 100644 (file)
@@ -28,13 +28,6 @@ config PPC_MSI_BITMAP
 source "arch/powerpc/sysdev/xics/Kconfig"
 source "arch/powerpc/sysdev/xive/Kconfig"
 
-config PPC_SCOM
-       bool
-
-config SCOM_DEBUGFS
-       bool "Expose SCOM controllers via debugfs"
-       depends on PPC_SCOM && DEBUG_FS
-
 config GE_FPGA
        bool
 
index 9d73dfddf0600a9b8b75787414120c9423970a0c..603b3c656d191e4f88b9e69c240feea2fb19fe19 100644 (file)
@@ -49,8 +49,6 @@ ifdef CONFIG_SUSPEND
 obj-$(CONFIG_PPC_BOOK3S_32)    += 6xx-suspend.o
 endif
 
-obj-$(CONFIG_PPC_SCOM)         += scom.o
-
 obj-$(CONFIG_PPC_EARLY_DEBUG_MEMCONS)  += udbg_memcons.o
 
 obj-$(CONFIG_PPC_XICS)         += xics/
diff --git a/arch/powerpc/sysdev/scom.c b/arch/powerpc/sysdev/scom.c
deleted file mode 100644 (file)
index 94e885b..0000000
+++ /dev/null
@@ -1,223 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Copyright 2010 Benjamin Herrenschmidt, IBM Corp
- *                <benh@kernel.crashing.org>
- *     and        David Gibson, IBM Corporation.
- */
-
-#include <linux/kernel.h>
-#include <linux/slab.h>
-#include <linux/export.h>
-#include <asm/debugfs.h>
-#include <asm/prom.h>
-#include <asm/scom.h>
-#include <linux/uaccess.h>
-
-const struct scom_controller *scom_controller;
-EXPORT_SYMBOL_GPL(scom_controller);
-
-struct device_node *scom_find_parent(struct device_node *node)
-{
-       struct device_node *par, *tmp;
-       const u32 *p;
-
-       for (par = of_node_get(node); par;) {
-               if (of_get_property(par, "scom-controller", NULL))
-                       break;
-               p = of_get_property(par, "scom-parent", NULL);
-               tmp = par;
-               if (p == NULL)
-                       par = of_get_parent(par);
-               else
-                       par = of_find_node_by_phandle(*p);
-               of_node_put(tmp);
-       }
-       return par;
-}
-EXPORT_SYMBOL_GPL(scom_find_parent);
-
-scom_map_t scom_map_device(struct device_node *dev, int index)
-{
-       struct device_node *parent;
-       unsigned int cells, size;
-       const __be32 *prop, *sprop;
-       u64 reg, cnt;
-       scom_map_t ret;
-
-       parent = scom_find_parent(dev);
-
-       if (parent == NULL)
-               return NULL;
-
-       /*
-        * We support "scom-reg" properties for adding scom registers
-        * to a random device-tree node with an explicit scom-parent
-        *
-        * We also support the simple "reg" property if the device is
-        * a direct child of a scom controller.
-        *
-        * In case both exist, "scom-reg" takes precedence.
-        */
-       prop = of_get_property(dev, "scom-reg", &size);
-       sprop = of_get_property(parent, "#scom-cells", NULL);
-       if (!prop && parent == dev->parent) {
-               prop = of_get_property(dev, "reg", &size);
-               sprop = of_get_property(parent, "#address-cells", NULL);
-       }
-       if (!prop)
-               return NULL;
-       cells = sprop ? be32_to_cpup(sprop) : 1;
-       size >>= 2;
-
-       if (index >= (size / (2*cells)))
-               return NULL;
-
-       reg = of_read_number(&prop[index * cells * 2], cells);
-       cnt = of_read_number(&prop[index * cells * 2 + cells], cells);
-
-       ret = scom_map(parent, reg, cnt);
-       of_node_put(parent);
-
-       return ret;
-}
-EXPORT_SYMBOL_GPL(scom_map_device);
-
-#ifdef CONFIG_SCOM_DEBUGFS
-struct scom_debug_entry {
-       struct device_node *dn;
-       struct debugfs_blob_wrapper path;
-       char name[16];
-};
-
-static ssize_t scom_debug_read(struct file *filp, char __user *ubuf,
-                              size_t count, loff_t *ppos)
-{
-       struct scom_debug_entry *ent = filp->private_data;
-       u64 __user *ubuf64 = (u64 __user *)ubuf;
-       loff_t off = *ppos;
-       ssize_t done = 0; 
-       u64 reg, reg_cnt, val;
-       scom_map_t map;
-       int rc;
-
-       if (off < 0 || (off & 7) || (count & 7))
-               return -EINVAL;
-       reg = off >> 3;
-       reg_cnt = count >> 3;
-
-       map = scom_map(ent->dn, reg, reg_cnt);
-       if (!scom_map_ok(map))
-               return -ENXIO;
-
-       for (reg = 0; reg < reg_cnt; reg++) {
-               rc = scom_read(map, reg, &val);
-               if (!rc)
-                       rc = put_user(val, ubuf64);
-               if (rc) {
-                       if (!done)
-                               done = rc;
-                       break;
-               }
-               ubuf64++;
-               *ppos += 8;
-               done += 8;
-       }
-       scom_unmap(map);
-       return done;
-}
-
-static ssize_t scom_debug_write(struct file* filp, const char __user *ubuf,
-                               size_t count, loff_t *ppos)
-{
-       struct scom_debug_entry *ent = filp->private_data;
-       u64 __user *ubuf64 = (u64 __user *)ubuf;
-       loff_t off = *ppos;
-       ssize_t done = 0; 
-       u64 reg, reg_cnt, val;
-       scom_map_t map;
-       int rc;
-
-       if (off < 0 || (off & 7) || (count & 7))
-               return -EINVAL;
-       reg = off >> 3;
-       reg_cnt = count >> 3;
-
-       map = scom_map(ent->dn, reg, reg_cnt);
-       if (!scom_map_ok(map))
-               return -ENXIO;
-
-       for (reg = 0; reg < reg_cnt; reg++) {
-               rc = get_user(val, ubuf64);
-               if (!rc)
-                       rc = scom_write(map, reg,  val);
-               if (rc) {
-                       if (!done)
-                               done = rc;
-                       break;
-               }
-               ubuf64++;
-               done += 8;
-       }
-       scom_unmap(map);
-       return done;
-}
-
-static const struct file_operations scom_debug_fops = {
-       .read =         scom_debug_read,
-       .write =        scom_debug_write,
-       .open =         simple_open,
-       .llseek =       default_llseek,
-};
-
-static int scom_debug_init_one(struct dentry *root, struct device_node *dn,
-                              int i)
-{
-       struct scom_debug_entry *ent;
-       struct dentry *dir;
-
-       ent = kzalloc(sizeof(*ent), GFP_KERNEL);
-       if (!ent)
-               return -ENOMEM;
-
-       ent->dn = of_node_get(dn);
-       snprintf(ent->name, 16, "%08x", i);
-       ent->path.data = (void*)kasprintf(GFP_KERNEL, "%pOF", dn);
-       ent->path.size = strlen((char *)ent->path.data);
-
-       dir = debugfs_create_dir(ent->name, root);
-       if (!dir) {
-               of_node_put(dn);
-               kfree(ent->path.data);
-               kfree(ent);
-               return -1;
-       }
-
-       debugfs_create_blob("devspec", 0400, dir, &ent->path);
-       debugfs_create_file("access", 0600, dir, ent, &scom_debug_fops);
-
-       return 0;
-}
-
-static int scom_debug_init(void)
-{
-       struct device_node *dn;
-       struct dentry *root;
-       int i, rc;
-
-       root = debugfs_create_dir("scom", powerpc_debugfs_root);
-       if (!root)
-               return -1;
-
-       i = rc = 0;
-       for_each_node_with_property(dn, "scom-controller") {
-               int id = of_get_ibm_chip_id(dn);
-               if (id == -1)
-                       id = i;
-               rc |= scom_debug_init_one(root, dn, id);
-               i++;
-       }
-
-       return rc;
-}
-device_initcall(scom_debug_init);
-#endif /* CONFIG_SCOM_DEBUGFS */