4 * Copyright 2010 Benjamin Herrenschmidt, IBM Corp.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #include <linux/cpumask.h>
15 #include <linux/spinlock.h>
16 #include <linux/types.h>
18 #include <asm/cputhreads.h>
19 #include <asm/reg_a2.h>
26 static scom_map_t wsp_scom_map(struct device_node *dev, u64 reg, u64 count)
31 if (!of_get_property(dev, "scom-controller", NULL)) {
32 pr_err("%s: device %s is not a SCOM controller\n",
33 __func__, dev->full_name);
34 return SCOM_MAP_INVALID;
37 if (of_address_to_resource(dev, 0, &r)) {
38 pr_debug("Failed to find SCOM controller address\n");
42 /* Transform the SCOM address into an XSCOM offset */
43 xscom_addr = ((reg & 0x7f000000) >> 1) | ((reg & 0xfffff) << 3);
45 return (scom_map_t)ioremap(r.start + xscom_addr, count << 3);
48 static void wsp_scom_unmap(scom_map_t map)
53 static int wsp_scom_read(scom_map_t map, u64 reg, u64 *value)
55 u64 __iomem *addr = (u64 __iomem *)map;
57 *value = in_be64(addr + reg);
62 static int wsp_scom_write(scom_map_t map, u64 reg, u64 value)
64 u64 __iomem *addr = (u64 __iomem *)map;
66 out_be64(addr + reg, value);
71 static const struct scom_controller wsp_scom_controller = {
73 .unmap = wsp_scom_unmap,
74 .read = wsp_scom_read,
75 .write = wsp_scom_write
78 void scom_init_wsp(void)
80 scom_init(&wsp_scom_controller);