Path: blob/master/arch/powerpc/platforms/wsp/scom_wsp.c
10818 views
/*1* SCOM backend for WSP2*3* Copyright 2010 Benjamin Herrenschmidt, IBM Corp.4*5* This program is free software; you can redistribute it and/or6* modify it under the terms of the GNU General Public License7* as published by the Free Software Foundation; either version8* 2 of the License, or (at your option) any later version.9*/1011#include <linux/cpumask.h>12#include <linux/io.h>13#include <linux/of.h>14#include <linux/spinlock.h>15#include <linux/types.h>1617#include <asm/cputhreads.h>18#include <asm/reg_a2.h>19#include <asm/scom.h>20#include <asm/udbg.h>2122#include "wsp.h"232425static scom_map_t wsp_scom_map(struct device_node *dev, u64 reg, u64 count)26{27struct resource r;28u64 xscom_addr;2930if (!of_get_property(dev, "scom-controller", NULL)) {31pr_err("%s: device %s is not a SCOM controller\n",32__func__, dev->full_name);33return SCOM_MAP_INVALID;34}3536if (of_address_to_resource(dev, 0, &r)) {37pr_debug("Failed to find SCOM controller address\n");38return 0;39}4041/* Transform the SCOM address into an XSCOM offset */42xscom_addr = ((reg & 0x7f000000) >> 1) | ((reg & 0xfffff) << 3);4344return (scom_map_t)ioremap(r.start + xscom_addr, count << 3);45}4647static void wsp_scom_unmap(scom_map_t map)48{49iounmap((void *)map);50}5152static u64 wsp_scom_read(scom_map_t map, u32 reg)53{54u64 __iomem *addr = (u64 __iomem *)map;5556return in_be64(addr + reg);57}5859static void wsp_scom_write(scom_map_t map, u32 reg, u64 value)60{61u64 __iomem *addr = (u64 __iomem *)map;6263return out_be64(addr + reg, value);64}6566static const struct scom_controller wsp_scom_controller = {67.map = wsp_scom_map,68.unmap = wsp_scom_unmap,69.read = wsp_scom_read,70.write = wsp_scom_write71};7273void scom_init_wsp(void)74{75scom_init(&wsp_scom_controller);76}777879