2006-01-04 12:31:30 -07:00
|
|
|
/*
|
2006-06-19 12:33:29 -06:00
|
|
|
* spu hypervisor abstraction for direct hardware access.
|
|
|
|
*
|
|
|
|
* (C) Copyright IBM Deutschland Entwicklung GmbH 2005
|
|
|
|
* Copyright 2006 Sony Corp.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2006-01-04 12:31:30 -07:00
|
|
|
*/
|
2006-06-19 12:33:29 -06:00
|
|
|
|
2006-11-22 16:46:49 -07:00
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/list.h>
|
2006-01-04 12:31:30 -07:00
|
|
|
#include <linux/module.h>
|
2006-11-22 16:46:49 -07:00
|
|
|
#include <linux/ptrace.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/wait.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/mutex.h>
|
|
|
|
#include <linux/device.h>
|
2006-01-04 12:31:30 -07:00
|
|
|
|
|
|
|
#include <asm/spu.h>
|
2006-06-19 12:33:29 -06:00
|
|
|
#include <asm/spu_priv1.h>
|
2006-11-22 16:46:49 -07:00
|
|
|
#include <asm/firmware.h>
|
|
|
|
#include <asm/prom.h>
|
2006-01-04 12:31:30 -07:00
|
|
|
|
2006-06-19 12:33:30 -06:00
|
|
|
#include "interrupt.h"
|
2006-11-22 16:46:49 -07:00
|
|
|
#include "spu_priv1_mmio.h"
|
|
|
|
|
2006-12-19 07:32:44 -07:00
|
|
|
static DEFINE_MUTEX(add_spumem_mutex);
|
|
|
|
|
2006-11-22 16:46:49 -07:00
|
|
|
struct spu_pdata {
|
|
|
|
struct device_node *devnode;
|
|
|
|
struct spu_priv1 __iomem *priv1;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct spu_pdata *spu_get_pdata(struct spu *spu)
|
|
|
|
{
|
|
|
|
BUG_ON(!spu->pdata);
|
|
|
|
return spu->pdata;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct device_node *spu_devnode(struct spu *spu)
|
|
|
|
{
|
|
|
|
return spu_get_pdata(spu)->devnode;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_SYMBOL_GPL(spu_devnode);
|
|
|
|
|
|
|
|
static int __init cell_spuprop_present(struct spu *spu, struct device_node *spe,
|
|
|
|
const char *prop)
|
|
|
|
{
|
|
|
|
const struct address_prop {
|
|
|
|
unsigned long address;
|
|
|
|
unsigned int len;
|
|
|
|
} __attribute__((packed)) *p;
|
|
|
|
int proplen;
|
|
|
|
|
|
|
|
unsigned long start_pfn, nr_pages;
|
|
|
|
struct pglist_data *pgdata;
|
|
|
|
struct zone *zone;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
p = get_property(spe, prop, &proplen);
|
|
|
|
WARN_ON(proplen != sizeof (*p));
|
|
|
|
|
|
|
|
start_pfn = p->address >> PAGE_SHIFT;
|
|
|
|
nr_pages = ((unsigned long)p->len + PAGE_SIZE - 1) >> PAGE_SHIFT;
|
|
|
|
|
2006-12-19 07:32:45 -07:00
|
|
|
pgdata = NODE_DATA(spu->node);
|
2006-11-22 16:46:49 -07:00
|
|
|
zone = pgdata->node_zones;
|
|
|
|
|
|
|
|
/* XXX rethink locking here */
|
|
|
|
mutex_lock(&add_spumem_mutex);
|
|
|
|
ret = __add_pages(zone, start_pfn, nr_pages);
|
|
|
|
mutex_unlock(&add_spumem_mutex);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __iomem * __init map_spe_prop(struct spu *spu,
|
|
|
|
struct device_node *n, const char *name)
|
|
|
|
{
|
|
|
|
const struct address_prop {
|
|
|
|
unsigned long address;
|
|
|
|
unsigned int len;
|
|
|
|
} __attribute__((packed)) *prop;
|
|
|
|
|
|
|
|
const void *p;
|
|
|
|
int proplen;
|
|
|
|
void __iomem *ret = NULL;
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
p = get_property(n, name, &proplen);
|
|
|
|
if (proplen != sizeof (struct address_prop))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
prop = p;
|
|
|
|
|
|
|
|
err = cell_spuprop_present(spu, n, name);
|
|
|
|
if (err && (err != -EEXIST))
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
ret = ioremap(prop->address, prop->len);
|
|
|
|
|
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void spu_unmap(struct spu *spu)
|
|
|
|
{
|
|
|
|
iounmap(spu->priv2);
|
|
|
|
iounmap(spu_get_pdata(spu)->priv1);
|
|
|
|
iounmap(spu->problem);
|
|
|
|
iounmap((__force u8 __iomem *)spu->local_store);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init spu_map_interrupts_old(struct spu *spu,
|
|
|
|
struct device_node *np)
|
|
|
|
{
|
|
|
|
unsigned int isrc;
|
|
|
|
const u32 *tmp;
|
2006-12-19 07:32:45 -07:00
|
|
|
int nid;
|
2006-11-22 16:46:49 -07:00
|
|
|
|
|
|
|
/* Get the interrupt source unit from the device-tree */
|
|
|
|
tmp = get_property(np, "isrc", NULL);
|
|
|
|
if (!tmp)
|
|
|
|
return -ENODEV;
|
|
|
|
isrc = tmp[0];
|
|
|
|
|
2006-12-19 07:32:45 -07:00
|
|
|
tmp = get_property(np->parent->parent, "node-id", NULL);
|
|
|
|
if (!tmp) {
|
|
|
|
printk(KERN_WARNING "%s: can't find node-id\n", __FUNCTION__);
|
|
|
|
nid = spu->node;
|
|
|
|
} else
|
|
|
|
nid = tmp[0];
|
|
|
|
|
2006-11-22 16:46:49 -07:00
|
|
|
/* Add the node number */
|
2006-12-19 07:32:45 -07:00
|
|
|
isrc |= nid << IIC_IRQ_NODE_SHIFT;
|
2006-11-22 16:46:49 -07:00
|
|
|
|
|
|
|
/* Now map interrupts of all 3 classes */
|
|
|
|
spu->irqs[0] = irq_create_mapping(NULL, IIC_IRQ_CLASS_0 | isrc);
|
|
|
|
spu->irqs[1] = irq_create_mapping(NULL, IIC_IRQ_CLASS_1 | isrc);
|
|
|
|
spu->irqs[2] = irq_create_mapping(NULL, IIC_IRQ_CLASS_2 | isrc);
|
|
|
|
|
|
|
|
/* Right now, we only fail if class 2 failed */
|
|
|
|
return spu->irqs[2] == NO_IRQ ? -EINVAL : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init spu_map_device_old(struct spu *spu, struct device_node *node)
|
|
|
|
{
|
|
|
|
const char *prop;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = -ENODEV;
|
|
|
|
spu->name = get_property(node, "name", NULL);
|
|
|
|
if (!spu->name)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
prop = get_property(node, "local-store", NULL);
|
|
|
|
if (!prop)
|
|
|
|
goto out;
|
|
|
|
spu->local_store_phys = *(unsigned long *)prop;
|
|
|
|
|
|
|
|
/* we use local store as ram, not io memory */
|
|
|
|
spu->local_store = (void __force *)
|
|
|
|
map_spe_prop(spu, node, "local-store");
|
|
|
|
if (!spu->local_store)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
prop = get_property(node, "problem", NULL);
|
|
|
|
if (!prop)
|
|
|
|
goto out_unmap;
|
|
|
|
spu->problem_phys = *(unsigned long *)prop;
|
|
|
|
|
|
|
|
spu->problem= map_spe_prop(spu, node, "problem");
|
|
|
|
if (!spu->problem)
|
|
|
|
goto out_unmap;
|
|
|
|
|
|
|
|
spu_get_pdata(spu)->priv1= map_spe_prop(spu, node, "priv1");
|
|
|
|
|
|
|
|
spu->priv2= map_spe_prop(spu, node, "priv2");
|
|
|
|
if (!spu->priv2)
|
|
|
|
goto out_unmap;
|
|
|
|
ret = 0;
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
out_unmap:
|
|
|
|
spu_unmap(spu);
|
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init spu_map_interrupts(struct spu *spu, struct device_node *np)
|
|
|
|
{
|
|
|
|
struct of_irq oirq;
|
|
|
|
int ret;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0; i < 3; i++) {
|
|
|
|
ret = of_irq_map_one(np, i, &oirq);
|
|
|
|
if (ret) {
|
|
|
|
pr_debug("spu_new: failed to get irq %d\n", i);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
ret = -EINVAL;
|
|
|
|
pr_debug(" irq %d no 0x%x on %s\n", i, oirq.specifier[0],
|
|
|
|
oirq.controller->full_name);
|
|
|
|
spu->irqs[i] = irq_create_of_mapping(oirq.controller,
|
|
|
|
oirq.specifier, oirq.size);
|
|
|
|
if (spu->irqs[i] == NO_IRQ) {
|
|
|
|
pr_debug("spu_new: failed to map it !\n");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err:
|
|
|
|
pr_debug("failed to map irq %x for spu %s\n", *oirq.specifier,
|
|
|
|
spu->name);
|
|
|
|
for (; i >= 0; i--) {
|
|
|
|
if (spu->irqs[i] != NO_IRQ)
|
|
|
|
irq_dispose_mapping(spu->irqs[i]);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-12-19 07:32:44 -07:00
|
|
|
static int spu_map_resource(struct spu *spu, int nr,
|
|
|
|
void __iomem** virt, unsigned long *phys)
|
2006-11-22 16:46:49 -07:00
|
|
|
{
|
2006-12-19 07:32:44 -07:00
|
|
|
struct device_node *np = spu_get_pdata(spu)->devnode;
|
|
|
|
unsigned long start_pfn, nr_pages;
|
|
|
|
struct pglist_data *pgdata;
|
|
|
|
struct zone *zone;
|
2006-11-22 16:46:49 -07:00
|
|
|
struct resource resource = { };
|
2006-12-19 07:32:44 -07:00
|
|
|
unsigned long len;
|
2006-11-22 16:46:49 -07:00
|
|
|
int ret;
|
|
|
|
|
2006-12-19 07:32:44 -07:00
|
|
|
ret = of_address_to_resource(np, nr, &resource);
|
2006-11-22 16:46:49 -07:00
|
|
|
if (ret)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (phys)
|
|
|
|
*phys = resource.start;
|
2006-12-19 07:32:44 -07:00
|
|
|
len = resource.end - resource.start + 1;
|
|
|
|
*virt = ioremap(resource.start, len);
|
2006-11-22 16:46:49 -07:00
|
|
|
if (!*virt)
|
|
|
|
ret = -EINVAL;
|
|
|
|
|
2006-12-19 07:32:44 -07:00
|
|
|
start_pfn = resource.start >> PAGE_SHIFT;
|
|
|
|
nr_pages = (len + PAGE_SIZE - 1) >> PAGE_SHIFT;
|
|
|
|
|
2006-12-19 07:32:45 -07:00
|
|
|
pgdata = NODE_DATA(spu->node);
|
2006-12-19 07:32:44 -07:00
|
|
|
zone = pgdata->node_zones;
|
|
|
|
|
|
|
|
/* XXX rethink locking here */
|
|
|
|
mutex_lock(&add_spumem_mutex);
|
|
|
|
ret = __add_pages(zone, start_pfn, nr_pages);
|
|
|
|
mutex_unlock(&add_spumem_mutex);
|
|
|
|
|
2006-11-22 16:46:49 -07:00
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-12-19 07:32:44 -07:00
|
|
|
static int __init spu_map_device(struct spu *spu)
|
2006-11-22 16:46:49 -07:00
|
|
|
{
|
2006-12-19 07:32:44 -07:00
|
|
|
struct device_node *np = spu_get_pdata(spu)->devnode;
|
2006-11-22 16:46:49 -07:00
|
|
|
int ret = -ENODEV;
|
2006-12-19 07:32:44 -07:00
|
|
|
|
|
|
|
spu->name = get_property(np, "name", NULL);
|
2006-11-22 16:46:49 -07:00
|
|
|
if (!spu->name)
|
|
|
|
goto out;
|
|
|
|
|
2006-12-19 07:32:44 -07:00
|
|
|
ret = spu_map_resource(spu, 0, (void __iomem**)&spu->local_store,
|
|
|
|
&spu->local_store_phys);
|
2006-11-22 16:46:49 -07:00
|
|
|
if (ret) {
|
|
|
|
pr_debug("spu_new: failed to map %s resource 0\n",
|
2006-12-19 07:32:44 -07:00
|
|
|
np->full_name);
|
2006-11-22 16:46:49 -07:00
|
|
|
goto out;
|
|
|
|
}
|
2006-12-19 07:32:44 -07:00
|
|
|
ret = spu_map_resource(spu, 1, (void __iomem**)&spu->problem,
|
|
|
|
&spu->problem_phys);
|
2006-11-22 16:46:49 -07:00
|
|
|
if (ret) {
|
|
|
|
pr_debug("spu_new: failed to map %s resource 1\n",
|
2006-12-19 07:32:44 -07:00
|
|
|
np->full_name);
|
2006-11-22 16:46:49 -07:00
|
|
|
goto out_unmap;
|
|
|
|
}
|
2006-12-19 07:32:44 -07:00
|
|
|
ret = spu_map_resource(spu, 2, (void __iomem**)&spu->priv2, NULL);
|
2006-11-22 16:46:49 -07:00
|
|
|
if (ret) {
|
|
|
|
pr_debug("spu_new: failed to map %s resource 2\n",
|
2006-12-19 07:32:44 -07:00
|
|
|
np->full_name);
|
2006-11-22 16:46:49 -07:00
|
|
|
goto out_unmap;
|
|
|
|
}
|
|
|
|
if (!firmware_has_feature(FW_FEATURE_LPAR))
|
2006-12-19 07:32:44 -07:00
|
|
|
ret = spu_map_resource(spu, 3,
|
|
|
|
(void __iomem**)&spu_get_pdata(spu)->priv1, NULL);
|
2006-11-22 16:46:49 -07:00
|
|
|
if (ret) {
|
|
|
|
pr_debug("spu_new: failed to map %s resource 3\n",
|
2006-12-19 07:32:44 -07:00
|
|
|
np->full_name);
|
2006-11-22 16:46:49 -07:00
|
|
|
goto out_unmap;
|
|
|
|
}
|
2006-12-19 07:32:44 -07:00
|
|
|
pr_debug("spu_new: %s maps:\n", np->full_name);
|
2006-11-22 16:46:49 -07:00
|
|
|
pr_debug(" local store : 0x%016lx -> 0x%p\n",
|
|
|
|
spu->local_store_phys, spu->local_store);
|
|
|
|
pr_debug(" problem state : 0x%016lx -> 0x%p\n",
|
|
|
|
spu->problem_phys, spu->problem);
|
|
|
|
pr_debug(" priv2 : 0x%p\n", spu->priv2);
|
|
|
|
pr_debug(" priv1 : 0x%p\n",
|
2006-12-19 07:32:44 -07:00
|
|
|
spu_get_pdata(spu)->priv1);
|
2006-11-22 16:46:49 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
out_unmap:
|
|
|
|
spu_unmap(spu);
|
|
|
|
out:
|
|
|
|
pr_debug("failed to map spe %s: %d\n", spu->name, ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init of_enumerate_spus(int (*fn)(void *data))
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct device_node *node;
|
|
|
|
|
|
|
|
ret = -ENODEV;
|
|
|
|
for (node = of_find_node_by_type(NULL, "spe");
|
|
|
|
node; node = of_find_node_by_type(node, "spe")) {
|
|
|
|
ret = fn(node);
|
|
|
|
if (ret) {
|
|
|
|
printk(KERN_WARNING "%s: Error initializing %s\n",
|
|
|
|
__FUNCTION__, node->name);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init of_create_spu(struct spu *spu, void *data)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct device_node *spe = (struct device_node *)data;
|
|
|
|
|
|
|
|
spu->pdata = kzalloc(sizeof(struct spu_pdata),
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!spu->pdata) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto out;
|
|
|
|
}
|
2006-12-19 07:32:44 -07:00
|
|
|
spu_get_pdata(spu)->devnode = of_node_get(spe);
|
2006-11-22 16:46:49 -07:00
|
|
|
|
2006-12-19 07:32:45 -07:00
|
|
|
spu->node = of_node_to_nid(spe);
|
2006-11-22 16:46:49 -07:00
|
|
|
if (spu->node >= MAX_NUMNODES) {
|
|
|
|
printk(KERN_WARNING "SPE %s on node %d ignored,"
|
|
|
|
" node number too big\n", spe->full_name, spu->node);
|
|
|
|
printk(KERN_WARNING "Check if CONFIG_NUMA is enabled.\n");
|
|
|
|
ret = -ENODEV;
|
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
|
2006-12-19 07:32:44 -07:00
|
|
|
ret = spu_map_device(spu);
|
2006-11-22 16:46:49 -07:00
|
|
|
/* try old method */
|
|
|
|
if (ret)
|
|
|
|
ret = spu_map_device_old(spu, spe);
|
|
|
|
if (ret)
|
|
|
|
goto out_free;
|
|
|
|
|
|
|
|
ret = spu_map_interrupts(spu, spe);
|
|
|
|
if (ret)
|
|
|
|
ret = spu_map_interrupts_old(spu, spe);
|
|
|
|
if (ret)
|
|
|
|
goto out_unmap;
|
|
|
|
|
|
|
|
pr_debug(KERN_DEBUG "Using SPE %s %p %p %p %p %d\n", spu->name,
|
|
|
|
spu->local_store, spu->problem, spu_get_pdata(spu)->priv1,
|
|
|
|
spu->priv2, spu->number);
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
out_unmap:
|
|
|
|
spu_unmap(spu);
|
|
|
|
out_free:
|
|
|
|
kfree(spu->pdata);
|
|
|
|
spu->pdata = NULL;
|
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int of_destroy_spu(struct spu *spu)
|
|
|
|
{
|
|
|
|
spu_unmap(spu);
|
|
|
|
of_node_put(spu_get_pdata(spu)->devnode);
|
|
|
|
kfree(spu->pdata);
|
|
|
|
spu->pdata = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct spu_management_ops spu_management_of_ops = {
|
|
|
|
.enumerate_spus = of_enumerate_spus,
|
|
|
|
.create_spu = of_create_spu,
|
|
|
|
.destroy_spu = of_destroy_spu,
|
|
|
|
};
|
2006-06-19 12:33:30 -06:00
|
|
|
|
2006-06-19 12:33:29 -06:00
|
|
|
static void int_mask_and(struct spu *spu, int class, u64 mask)
|
2006-01-04 12:31:30 -07:00
|
|
|
{
|
|
|
|
u64 old_mask;
|
|
|
|
|
2006-11-22 16:46:49 -07:00
|
|
|
old_mask = in_be64(&spu_get_pdata(spu)->priv1->int_mask_RW[class]);
|
|
|
|
out_be64(&spu_get_pdata(spu)->priv1->int_mask_RW[class],
|
|
|
|
old_mask & mask);
|
2006-01-04 12:31:30 -07:00
|
|
|
}
|
|
|
|
|
2006-06-19 12:33:29 -06:00
|
|
|
static void int_mask_or(struct spu *spu, int class, u64 mask)
|
2006-01-04 12:31:30 -07:00
|
|
|
{
|
|
|
|
u64 old_mask;
|
|
|
|
|
2006-11-22 16:46:49 -07:00
|
|
|
old_mask = in_be64(&spu_get_pdata(spu)->priv1->int_mask_RW[class]);
|
|
|
|
out_be64(&spu_get_pdata(spu)->priv1->int_mask_RW[class],
|
|
|
|
old_mask | mask);
|
2006-01-04 12:31:30 -07:00
|
|
|
}
|
|
|
|
|
2006-06-19 12:33:29 -06:00
|
|
|
static void int_mask_set(struct spu *spu, int class, u64 mask)
|
2006-01-04 12:31:30 -07:00
|
|
|
{
|
2006-11-22 16:46:49 -07:00
|
|
|
out_be64(&spu_get_pdata(spu)->priv1->int_mask_RW[class], mask);
|
2006-01-04 12:31:30 -07:00
|
|
|
}
|
|
|
|
|
2006-06-19 12:33:29 -06:00
|
|
|
static u64 int_mask_get(struct spu *spu, int class)
|
2006-01-04 12:31:30 -07:00
|
|
|
{
|
2006-11-22 16:46:49 -07:00
|
|
|
return in_be64(&spu_get_pdata(spu)->priv1->int_mask_RW[class]);
|
2006-01-04 12:31:30 -07:00
|
|
|
}
|
|
|
|
|
2006-06-19 12:33:29 -06:00
|
|
|
static void int_stat_clear(struct spu *spu, int class, u64 stat)
|
2006-01-04 12:31:30 -07:00
|
|
|
{
|
2006-11-22 16:46:49 -07:00
|
|
|
out_be64(&spu_get_pdata(spu)->priv1->int_stat_RW[class], stat);
|
2006-01-04 12:31:30 -07:00
|
|
|
}
|
|
|
|
|
2006-06-19 12:33:29 -06:00
|
|
|
static u64 int_stat_get(struct spu *spu, int class)
|
2006-01-04 12:31:30 -07:00
|
|
|
{
|
2006-11-22 16:46:49 -07:00
|
|
|
return in_be64(&spu_get_pdata(spu)->priv1->int_stat_RW[class]);
|
2006-01-04 12:31:30 -07:00
|
|
|
}
|
|
|
|
|
2006-06-19 12:33:30 -06:00
|
|
|
static void cpu_affinity_set(struct spu *spu, int cpu)
|
2006-01-04 12:31:30 -07:00
|
|
|
{
|
2006-06-19 12:33:30 -06:00
|
|
|
u64 target = iic_get_target_id(cpu);
|
|
|
|
u64 route = target << 48 | target << 32 | target << 16;
|
2006-11-22 16:46:49 -07:00
|
|
|
out_be64(&spu_get_pdata(spu)->priv1->int_route_RW, route);
|
2006-01-04 12:31:30 -07:00
|
|
|
}
|
|
|
|
|
2006-06-19 12:33:29 -06:00
|
|
|
static u64 mfc_dar_get(struct spu *spu)
|
2006-01-04 12:31:30 -07:00
|
|
|
{
|
2006-11-22 16:46:49 -07:00
|
|
|
return in_be64(&spu_get_pdata(spu)->priv1->mfc_dar_RW);
|
2006-01-04 12:31:30 -07:00
|
|
|
}
|
|
|
|
|
2006-06-19 12:33:29 -06:00
|
|
|
static u64 mfc_dsisr_get(struct spu *spu)
|
2006-01-04 12:31:30 -07:00
|
|
|
{
|
2006-11-22 16:46:49 -07:00
|
|
|
return in_be64(&spu_get_pdata(spu)->priv1->mfc_dsisr_RW);
|
2006-01-04 12:31:30 -07:00
|
|
|
}
|
|
|
|
|
2006-06-19 12:33:29 -06:00
|
|
|
static void mfc_dsisr_set(struct spu *spu, u64 dsisr)
|
2006-01-04 12:31:30 -07:00
|
|
|
{
|
2006-11-22 16:46:49 -07:00
|
|
|
out_be64(&spu_get_pdata(spu)->priv1->mfc_dsisr_RW, dsisr);
|
2006-01-04 12:31:30 -07:00
|
|
|
}
|
|
|
|
|
2006-10-24 10:31:14 -06:00
|
|
|
static void mfc_sdr_setup(struct spu *spu)
|
2006-01-04 12:31:30 -07:00
|
|
|
{
|
2006-11-22 16:46:49 -07:00
|
|
|
out_be64(&spu_get_pdata(spu)->priv1->mfc_sdr_RW, mfspr(SPRN_SDR1));
|
2006-01-04 12:31:30 -07:00
|
|
|
}
|
|
|
|
|
2006-06-19 12:33:29 -06:00
|
|
|
static void mfc_sr1_set(struct spu *spu, u64 sr1)
|
2006-01-04 12:31:30 -07:00
|
|
|
{
|
2006-11-22 16:46:49 -07:00
|
|
|
out_be64(&spu_get_pdata(spu)->priv1->mfc_sr1_RW, sr1);
|
2006-01-04 12:31:30 -07:00
|
|
|
}
|
|
|
|
|
2006-06-19 12:33:29 -06:00
|
|
|
static u64 mfc_sr1_get(struct spu *spu)
|
2006-01-04 12:31:30 -07:00
|
|
|
{
|
2006-11-22 16:46:49 -07:00
|
|
|
return in_be64(&spu_get_pdata(spu)->priv1->mfc_sr1_RW);
|
2006-01-04 12:31:30 -07:00
|
|
|
}
|
|
|
|
|
2006-06-19 12:33:29 -06:00
|
|
|
static void mfc_tclass_id_set(struct spu *spu, u64 tclass_id)
|
2006-01-04 12:31:30 -07:00
|
|
|
{
|
2006-11-22 16:46:49 -07:00
|
|
|
out_be64(&spu_get_pdata(spu)->priv1->mfc_tclass_id_RW, tclass_id);
|
2006-01-04 12:31:30 -07:00
|
|
|
}
|
|
|
|
|
2006-06-19 12:33:29 -06:00
|
|
|
static u64 mfc_tclass_id_get(struct spu *spu)
|
2006-01-04 12:31:30 -07:00
|
|
|
{
|
2006-11-22 16:46:49 -07:00
|
|
|
return in_be64(&spu_get_pdata(spu)->priv1->mfc_tclass_id_RW);
|
2006-01-04 12:31:30 -07:00
|
|
|
}
|
|
|
|
|
2006-06-19 12:33:29 -06:00
|
|
|
static void tlb_invalidate(struct spu *spu)
|
2006-01-04 12:31:30 -07:00
|
|
|
{
|
2006-11-22 16:46:49 -07:00
|
|
|
out_be64(&spu_get_pdata(spu)->priv1->tlb_invalidate_entry_W, 0ul);
|
2006-01-04 12:31:30 -07:00
|
|
|
}
|
|
|
|
|
2006-06-19 12:33:29 -06:00
|
|
|
static void resource_allocation_groupID_set(struct spu *spu, u64 id)
|
2006-01-04 12:31:30 -07:00
|
|
|
{
|
2006-11-22 16:46:49 -07:00
|
|
|
out_be64(&spu_get_pdata(spu)->priv1->resource_allocation_groupID_RW,
|
|
|
|
id);
|
2006-01-04 12:31:30 -07:00
|
|
|
}
|
|
|
|
|
2006-06-19 12:33:29 -06:00
|
|
|
static u64 resource_allocation_groupID_get(struct spu *spu)
|
2006-01-04 12:31:30 -07:00
|
|
|
{
|
2006-11-22 16:46:49 -07:00
|
|
|
return in_be64(
|
|
|
|
&spu_get_pdata(spu)->priv1->resource_allocation_groupID_RW);
|
2006-01-04 12:31:30 -07:00
|
|
|
}
|
|
|
|
|
2006-06-19 12:33:29 -06:00
|
|
|
static void resource_allocation_enable_set(struct spu *spu, u64 enable)
|
2006-01-04 12:31:30 -07:00
|
|
|
{
|
2006-11-22 16:46:49 -07:00
|
|
|
out_be64(&spu_get_pdata(spu)->priv1->resource_allocation_enable_RW,
|
|
|
|
enable);
|
2006-01-04 12:31:30 -07:00
|
|
|
}
|
|
|
|
|
2006-06-19 12:33:29 -06:00
|
|
|
static u64 resource_allocation_enable_get(struct spu *spu)
|
2006-01-04 12:31:30 -07:00
|
|
|
{
|
2006-11-22 16:46:49 -07:00
|
|
|
return in_be64(
|
|
|
|
&spu_get_pdata(spu)->priv1->resource_allocation_enable_RW);
|
2006-01-04 12:31:30 -07:00
|
|
|
}
|
2006-06-19 12:33:29 -06:00
|
|
|
|
|
|
|
const struct spu_priv1_ops spu_priv1_mmio_ops =
|
|
|
|
{
|
|
|
|
.int_mask_and = int_mask_and,
|
|
|
|
.int_mask_or = int_mask_or,
|
|
|
|
.int_mask_set = int_mask_set,
|
|
|
|
.int_mask_get = int_mask_get,
|
|
|
|
.int_stat_clear = int_stat_clear,
|
|
|
|
.int_stat_get = int_stat_get,
|
2006-06-19 12:33:30 -06:00
|
|
|
.cpu_affinity_set = cpu_affinity_set,
|
2006-06-19 12:33:29 -06:00
|
|
|
.mfc_dar_get = mfc_dar_get,
|
|
|
|
.mfc_dsisr_get = mfc_dsisr_get,
|
|
|
|
.mfc_dsisr_set = mfc_dsisr_set,
|
2006-10-24 10:31:14 -06:00
|
|
|
.mfc_sdr_setup = mfc_sdr_setup,
|
2006-06-19 12:33:29 -06:00
|
|
|
.mfc_sr1_set = mfc_sr1_set,
|
|
|
|
.mfc_sr1_get = mfc_sr1_get,
|
|
|
|
.mfc_tclass_id_set = mfc_tclass_id_set,
|
|
|
|
.mfc_tclass_id_get = mfc_tclass_id_get,
|
|
|
|
.tlb_invalidate = tlb_invalidate,
|
|
|
|
.resource_allocation_groupID_set = resource_allocation_groupID_set,
|
|
|
|
.resource_allocation_groupID_get = resource_allocation_groupID_get,
|
|
|
|
.resource_allocation_enable_set = resource_allocation_enable_set,
|
|
|
|
.resource_allocation_enable_get = resource_allocation_enable_get,
|
|
|
|
};
|